Skip to content

`shell-glossary` is a glossary of reusable POSIX shell functions.

License

Notifications You must be signed in to change notification settings

mscalindt/shell-glossary

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Table of Contents

  1. Introduction
  2. Roadmap
  3. Contributing
  4. License
  5. Notice
  6. Author
  7. Collection 1: General POSIX Shell Functions
  8. Collection 2: POSIX Shell Functions for Shell Option Parsing

1. Introduction

shell-glossary is a glossary of reusable POSIX shell functions. It features collections of optimized functions for general use.

Currently, the state of the functions is considered unstable until certain criteria in Roadmap are met.

2. Roadmap

  • Unit tests (wunit).
    • Transition to versioned release tags.
    • Makefile to run the unit tests.
  • Shell code style guide.
    • Assert code for style.
  • Assertable function documentation header syntax.
    • Assertable function documentation header.
  • Manpage of shell-glossary.
    • Provide manpage equivalents of the function documentation headers.
  • Makefile to build src/ into a shell-glossary file.

3. Contributing

Contribution guidelines will be published in the future. At this time, external contributions are not accepted.

For a list of people who have contributed to shell-glossary, see the CREDITS file.

4. License

BSD 2-Clause "Simplified" License

For a list of external dependencies and their licenses, refer to the DEPENDENCIES file.

5. Notice

This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

For detailed information on external dependencies, see the DEPENDENCIES file.

6. Author

Dimitar Yurukov (mscalindt@protonmail.com)


Collection 1: General POSIX Shell Functions

A collection of reusable pure and very portable shell 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
  • PATH_STRIP(): Strip a path N segments RTL
  • 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 Shell Functions for Shell Option Parsing

A collection of reusable pure and very portable shell 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

About

`shell-glossary` is a glossary of reusable POSIX shell functions.

Topics

Resources

License

Stars

Watchers

Forks