Skip to content
/ scripts Public

Miscellaneous files to help you write smart shell scripts

Notifications You must be signed in to change notification settings

nyxnor/scripts

Repository files navigation

Scripts - Some critical relevant interesting parsimonious temendrous scripts

Useful configuration files and executables to facilitate every day development.

The intent of this repository is to be an advanced tutorial, but you will have to read scripts instead of markdown, paying attention to the code comments.


Table of Contents


Requirements

  • Unix like system with a POSIX compliant shell (sh, ash, dash, bash, ksh, zsh etc) and standard shell utilities (grep, sed, find etc).
  • Some shellscripting knowledge as this is not a begginers guide. To learn, see the reading topic.

Configuration files

  • .editorconfig - EditorConfig helps maintain consistent coding styles for multiple developers working on the same project across various editors and IDEs
  • .shellcheckrc - Shellcheck run commands file

Scripts

  • check-progs.sh - check if program is installed (placed on PATH) and executable.
  • expansions.sh - useful expansions to get script name, correct folder path, assign default values if key is empty or unset.
  • formatting.sh - tips on formatting your scripts, dedicated to emphatization, colors, bold, underline, error messages.
  • getopts.sh - enhanced getopts to accept long and short options, as well as requiring arguments, checking if arguments are within range, setting default values to not brek tests and arguments expressed after an equal sign (--option=arg).
  • permission.sh - bulk/recursively permission set for all files and folders inside chosen directory. Commonly used with folder 755 and file 644, or folder 700 and file 600.
  • toc.sh - build markdown table of contents, check if header is repeated. Requires the header to be set by hashtag (#), not by equals (===) nor by hifens (---).

Reading

Materials referenced here are a must read before any question is asked.

Development

To add new scripts, the following rules will be taken into consideration:

Portability

  • POSIX compliant
  • Platform agnostic

Usability

  • It is faster to understand the options and run the script than to do the tasks manually

Coding style

  • Respects the coding standard or enhances it
  • Has code comments
  • Has usage message
  • Function names starts with a verb
  • Variables name starts with a noun

Syntax

Releases

No releases published

Packages

No packages published

Languages