| 1 | # Two functions I actually use, all the time. |
| 2 | # |
| 3 | # To keep depenedencies small, this library will NEVER grow other functions |
| 4 | # (and is named to imply that.) |
| 5 | # |
| 6 | # Usage: |
| 7 | # source --builtin two.sh |
| 8 | # |
| 9 | # Examples: |
| 10 | # log 'hi' |
| 11 | # die 'expected a number' |
| 12 | |
| 13 | log() { |
| 14 | ### Write a message to stderr. |
| 15 | echo "$@" >&2 |
| 16 | } |
| 17 | |
| 18 | die() { |
| 19 | ### Write an error message with the script name, and exit failure. |
| 20 | log "$0: fatal: $@" |
| 21 | exit 1 |
| 22 | } |
| 23 |