a Bash API improvement and enhancements with logging, debugging, command parameters and more.
- includes different modules to be imported via
source(1) log: a powerful logging API with log levels, colors, custom formatting, writes to different output descriptorsparam2env: maps command line parameters to ordinary environment variables, likesenv(1)command. A valid alternative to classicgetoptor--optionstyle cli.location: knows where its own script is located, regardless of symlinks ("canonization path")temp: provides temporary files viamktemp(1), hold names in order to be removed ones the script terminates; the programmer simply calls a cleanup method when exit.debug: providesassert()function, plus a bash stack and a unix stack trace dump functions
- get
pegasus-bash:
mkdir $HOME/my/dir && cd $HOME/my/dir
git clone https://github.com/bzimage-it/pegasus-bash/
- set
PEGASUS_BASH_ROOTproperly; you can do at beginning of your script:
#!/bin/bash
PEGASUS_BASH_ROOT=$HOME/my/dir/pegasus-bash
source $PEGASUS_BASH_ROOT/pegasus-bash.sh all
# ....my code follows....
note that setting of PEGASUS_BASH_ROOT is mandatory before to source(1) pegasus-bash
- you may want to
exportit in.bashrc, or wherever you like:
export PEGASUS_BASH_ROOT=$HOME/my/dir/pegasus-bash
a quickstart.sh script using pegasus-bash:
$ cd examples
$ bash quickstart.sh foo=123 A=astring Directory= /tmp/
see log.sh example
target of this project is to have good testing and a good code review. This will be available in 1.0.0 release.
the script bash quality.sh helps to run static analysis (via shellcheck) and dynamic/unit testing (via bats-core); you needs both of them to test pegasus-bash, but they are not needed to use the library.
Any recent linux distro shall works (but also not-too-much-older ones!) It have been tested successfully on:
bash 5.2.21onUbuntu 24.04.1 LTS
Let me know other test setup that is working or not. Thank you!
see TODO file

