Skip to content

mscalindt/shell-glossary

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

Collection 1: General POSIX sh Functions

A collection of reusable pure and very portable sh functions with optional external utility calls.

Functions List:

  • ARG_SAVE(): Save with single-quote escape an argument into a variable
  • CCOUNT(): Count the times a character appears in a string
  • CONFIRM_CONT(): Ask for confirmation to continue
  • COUNT_DIR(): Count visible directories in a directory
  • COUNT_DIR_DOT(): Count .* (dot/hidden) directories in a directory
  • COUNT_FILE(): Count visible file objects in a directory
  • COUNT_FILE_DOT(): Count .* (dot/hidden) file objects in a directory
  • COUNT_OBJ(): Count all visible objects in a directory
  • COUNT_OBJ_DOT(): Count all .* (dot/hidden) objects in a directory
  • ERR(): Print formatted text to stderr
  • ERRF(): Print red-colored formatted text to stderr and exit
  • ESC_SED(): Escape a string to be used literally as a POSIX sed string
  • FILE_PRELOAD(): Read a file raw
  • FLINE(): Get a specific line in a file
  • FTYPE(): Identify the type of an object on the filesystem
  • INFO(): Print formatted text
  • MAP(): Process each argument with a function
  • MAP_FIND(): Find success among arguments using a function
  • MAP_FLINE(): Process each populated file line with a function
  • MAP_PCHUNK(): Process each cumulative path segment with a function
  • MAP_PCHUNK_FIND(): Find success among cumulative path segments using a function
  • MAP_PCHUNK_FIND_REV(): Find success among cumulative path segments in reverse using a function
  • MAP_PCHUNK_REV(): Process each cumulative path segment in reverse with a function
  • MAP_PSEG(): Process each path segment with a function
  • MAP_PSEG_FIND(): Find success among path segments using a function
  • MAP_PSEG_FIND_REV(): Find success among path segments in reverse using a function
  • MAP_PSEG_REV(): Process each path segment in reverse with a function
  • MAP_VLINE(): Process each populated string line with a function
  • MASK_CHECK(): Check a bit, the power of 2, in a pseudo-bitmask shell variable
  • MASK_SET(): Set a bit, the power of 2, in a pseudo-bitmask shell variable
  • MASK_UNSET(): Unset a bit, the power of 2, in a pseudo-bitmask shell variable
  • NUM_TO_CHAR(): Convert N to that amount of a character
  • PATH_SPEC(): Lexically normalize a path into an assertable canonical path
  • PATH_SPEC_FS(): Semantically normalize a path into an assertable canonical path
  • PATH_SPEC_STATIC(): Modify a path string
  • REPLCHAR(): Replace a specific character with character(s) in a string
  • SQ_ARG(): Get N evaluated argument in a single-quotes array of arguments
  • SQ_ARG_EXTRACT(): Extract an evaluated argument in a single-quotes array of arguments

Collection 2: POSIX sh Functions for Shell Option Parsing

A collection of reusable pure and very portable sh functions to make shell option parsing a breeze.

Functions List:

  • ABSPATH(): Convert a relative pathname into an absolute pathname
  • ASSERT(): Assert a string
  • CFG_FAIL(): Signify bad configuration file and exit
  • COPT(): Match --delimited short/long option with a mandatory option argument
  • COPT_OPTIONAL(): Match --delimited short/long option with an optional option argument
  • OPD_MAX(): Signify operand count exceeds maximum allowed
  • OPD_MIN(): Signify operand count below minimum required
  • OPT_COMPAT_FAIL(): Signify option incompatibility with a previous option and exit
  • OPT_ERR(): Signify option failure
  • OPT_FAIL(): Signify option failure and exit
  • OPT_INVALID(): Signify invalid short option
  • OPT_UNKNOWN(): Signify unknown option
  • OPT_UNRECOGNIZED(): Signify unrecognized long option
  • SCOPT(): Match specific option(s) with a mandatory option argument
  • SCOPT_OPTIONAL(): Match specific option(s) with an optional option argument
  • SOPT(): Match --delimited short/long option without an option argument
  • SSOPT(): Match specific option(s) without an option argument