mirror of
https://github.com/kvz/bash3boilerplate.git
synced 2024-12-18 22:27:51 +00:00
Simplify example in readme (#133)
This commit is contained in:
parent
1238b67abe
commit
269627deec
@ -98,12 +98,11 @@ As of `v1.0.3`, b3bp offers some nice re-usable libraries in `./src`. In order t
|
||||
It is nice to have a Bash package that can not only be used in the terminal, but also invoked as a command line function. In order to achieve this, the exporting of your functionality *should* follow this pattern:
|
||||
|
||||
```bash
|
||||
if [[ "${BASH_SOURCE[0]}" != "${0}" ]]; then
|
||||
export -f my_script
|
||||
else
|
||||
if [[ "${BASH_SOURCE[0]}" = "${0}" ]]; then
|
||||
my_script "${@}"
|
||||
exit $?
|
||||
fi
|
||||
export -f my_script
|
||||
```
|
||||
|
||||
This allows a user to `source` your script or invoke it as a script.
|
||||
|
Loading…
Reference in New Issue
Block a user