Let's be honest; bash for developers is not that straightforward. And that's exactly why I made the bash library.
How many of you wish you can use console.log inside a terminal instead of echo Hello world? If you are one, you should check this out.
A Core library for bash Bourne
To quickly set up the bash-lib library, run the following command:
curl -sSL https://raw.githubusercontent.com/mohammadchehab/bash-lib/main/install.sh -o /tmp/install.sh && bash /tmp/install.shThis script will:
- Download the
bash-lib.shfile. - Move it to
/opt/bash-lib. - Modify your shell profile to source
bash-lib.shautomatically. - Source
bash-lib.shin the current session.
curl -sSL https://raw.githubusercontent.com/mohammadchehab/bash-lib/main/install.sh -o /tmp/install.sh && bash /tmp/install.sh uninstallgit clone https://github.com/mohammadchehab/bash-lib && \
cd bash-lib && \
export BASH__PATH=~/develop/bash-lib && \
source ${BASH__PATH}/core/init.shimport console # this will load up the console moduleOnce the module is loaded into the terminal you can start using the methods
console.log Hello world!
#output
03/03/2021 11:25:33 - Mohammads-MacBook-Pro.local - bash - [LOG]: Hello world!another example in one shot
import http && \
http.get http://stash.compciv.org/congress-twitter/json/joni-ernst.jsonYou can simply de-register the module using the unset command
unset console;You can query the available modules using
engine.modules| Variable | Description |
|---|---|
BASH__PATH |
This is the root location of the library |
BASH__VERBOSE |
You can set it to one of the log levels TRACE, DEBUG, INFO, WARN or ERROR to change the verbosity of the logs. TRACE is the most verbose and it is the default |
| Convention | Description |
|---|---|
| Class level variables in modules | Variables in modules will be named as such BASHLIB__MODULENAME__VARIABLE__NAME |
| Environment Scope | Variables with environment scope will be as VARIABLE__NAME |
At the end of the day this is pure bash. To turn on debugging simply use
set -xOnce done you can simply switch it off using the following command.
set +xCheck the BASH environment variables that are loaded
env | sed "s/=.*//" | grep BASH
# example output
BASH__PATH
BASH__VERBOSELib Bash uses shellspec to perform unit tests.
all the test cases are stored under the spec directory. to run the tests simply use make
Don't know where to start yet?
egrep -Rin "TODO|FIXME" -R *see here for the complete chanelog
