bashsh
Improves your Bash scripts
Improves your Bash scripts.
Usage
The following shebang
#!/usr/bin/env bashsh-0
gives you:
set -eby default:
$ echo hello ; false ; echo world
will only print hello.
CMDfor showing executed commands in bold on stderr:
$ CMD git status
CMD_STRprints the string in bold on stderr and runs it witheval:
$ CMD_STR 'gitk --all &'
MSGprints a remark in bold on stderr, formatted as a comment:
$ MSG hello world
prints # hello world.
READ_Pworks likeread -pbut prints the first parameter usingMSG:
$ READ_P 'What is your name? ' your_name
QUOTEDprints the given arguments in a way that is safe to pass to commands:
$ echo "My arguments are: $(QUOTED "$@")"
You can find a few examples in the examples directory.
Caveats / known limitations
You cannot just
bpkg install bashsh
to install bashsh locally (it is forced to install globally anyway), because if you use
#!/usr/bin/env ./relative/path/to/bashsh-0
the path of the command supplied to env will be interpreted as relative to the working directory, not to the script’s directory.
Links
- Source Code (GitHub)
- Author: Felix Rabe
blog comments powered by Disqus