SemVer. More consistent docs

This commit is contained in:
Kevin van Zonneveld 2013-02-25 23:54:34 +01:00
parent d309bba768
commit 6aadcb3222
2 changed files with 14 additions and 17 deletions

View File

@ -1,15 +1,10 @@
There are many cases where using BASH to code ends up
overcomplicating things. But due to it's portability (BASH is everywhere)
there are plenty of cases where it makes sense to use BASH over other more
dependcy-heavy languages.
When I do hack up a BASH script, I often find there are some
When hacking up BASH scripts, I often find there are some
higherlevel things like logging, configuration, commandline argument
parsing that
parsing that:
- I need everytime
- take quite some effort to get right, and
- keep you from your actual work.
- Take quite some effort to get right
- Keep you from your actual work
Here's an attempt to bundle those things in a generalized way so that
they are reusable as-is in most of my (and hopefully your, if not ping
@ -54,22 +49,24 @@ so no duplication needed)
## Conventions
It's the task of the script's **caller** to:
- redirect the output to appropriate locations
- correctly set the PATH variable (think [cronjobs](http://kvz.io/blog/2007/07/29/schedule-tasks-on-linux-using-crontab/))
- Redirect the output to appropriate locations
- Correctly set the PATH variable (think [cronjobs](http://kvz.io/blog/2007/07/29/schedule-tasks-on-linux-using-crontab/))
## Recommendations
- using spaces vs tabs so you can copy-paste parts directly into
- Use spaces vs tabs so you can copy-paste parts directly into
the console, without BASH's automcomplete firing on every tab
character
- using `set -eu`, so it will break on every error
and undefined variable. if you're expecting an error, add ||true
- Use `set -eu`, so it will break on every error
and undefined variable. if you're expecting an error, add `||true`
to your command.
- checkout [The 10 Commandments of Logging](http://www.masterzen.fr/2013/01/13/the-10-commandments-of-logging/)
Using `set -eu` over the interpreter `#!/bin/bash -eu` makes
sure the flags are respected even when your script is called like `bash main.sh`.
- Checkout [The 10 Commandments of Logging](http://www.masterzen.fr/2013/01/13/the-10-commandments-of-logging/)
## Notes
- use `emergency` to exit with 1
- Use `emergency` to exit with 1
## Compile

View File

@ -1,7 +1,7 @@
#!/bin/bash
#
# Template to write better bash scripts. More info: http://kvz.io
# Version 0.01
# Version 0.0.1
#
# Usage:
# LOG_LEVEL=7 ./template.sh first_arg second_arg