Skip to content

mscalindt/shell-glossary

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2,454 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Table of Contents

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

Introduction

shell-glossary is a glossary of reusable POSIX shell functions. It features collections of optimized functions for general use; or about ~4K portable (and documented) LOC with powerful capabilities, precisely.

$ bash showcase.sh "$PWD"/src
20260328
real 0.05
user 0.05
sys 0.00
4127 LOC

$ cat showcase.sh
git describe
for f in "$1"/*; do . "$f"; done
c() { c="$((${c:-0}+1))"; }
time -p { for f in "$1"/*; do for_fline -shell "$f" c; done; }
printf "%s\n" "$c LOC"

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

Roadmap

  • Portable C89 in-house program to follow/resolve symbolic links.
  • Unit tests (wunit).
    • Makefile to run the unit tests.
  • Benchmarks in bash, dash, ksh.
  • 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.

Releases

Source code releases follow the YYYYMMDD format.

To list the available releases, check out the available tags or use git tag.

For updates on recent changes, see the NEWS file. Changes that break backward compatibility should always be mentioned.

Contributors

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.

License

KEYCLA 1.0 License

Notice

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


Collection 1: General POSIX Shell Functions

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

  • ABSPATH(): Convert a relative pathname into an absolute pathname
  • ARG_SAVE(): Save with single-quote escape an argument into a variable
  • ARG_SET(): Set with single-quote escape an argument into a variable
  • ASSERT(): Assert a string
  • CCOUNT(): Count the times character(s) appear in a string using IFS
  • CCOUNT_POSIX(): Count the times a character appears in a string using PE
  • CONFIRM_CONT(): Assert 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
  • ESC_SED(): Escape a string to be used literally as a POSIX sed string
  • FED(): Create a deterministic file data edit format
  • FILE_PRELOAD(): Read a file into a variable
  • FLINE(): Get a specific line in a file
  • FMODE_OCTAL(): Convert octal to "file mode" string
  • FOR_FLINE(): Process each populated file line with a function
  • FOR_IFS(): Process each populated IFS field split with a function
  • FOR_PCHUNK(): Process each cumulative path segment with a function
  • FOR_PCHUNK_FIND(): Find success among cumulative path segments using a function
  • FOR_PCHUNK_FIND_REV(): Find success among cumulative path segments in reverse using a function
  • FOR_PCHUNK_REV(): Process each cumulative path segment in reverse with a function
  • FOR_SLINE(): Process each populated string line with a function
  • FTYPE(): Identify the type of an object on the filesystem
  • INFO(): Print formatted text
  • LIBFILE(): Modify regular file data in-memory using a deterministic format
  • LIBFILE_N_ADD(): For natural N, add line content
  • LIBFILE_N_REM(): For natural N, remove line string
  • MAP(): Process each argument with a function
  • MAP_FIND(): Find success among arguments using a function
  • MAP_FIND_REV(): Find success among arguments in reverse using a function
  • MAP_REV(): Process each argument in reverse with a function
  • MAP_TRY(): Process each argument with a function irrespective of rc
  • MAP_TRY_REV(): Process each argument in reverse with a function irrespective of rc
  • MASK_CHECK(): Assert 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(): Create N amount of character(s) using PE
  • 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 specific character(s) with character(s) in a string using IFS
  • REPLCHAR_POSIX(): Replace a specific character with character(s) in a string using PE
  • REPLSTR_SED_POSIX(): Replace a substring with character(s) in a string using sed
  • SLINE(): Get a specific line 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.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Contributors