OILS / stdlib / osh / two.sh View on Github | oilshell.org

27 lines, 10 significant
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
13if command -v source-guard >/dev/null; then # include guard for YSH
14 source-guard two || return 0
15fi
16
17log() {
18 ### Write a message to stderr.
19 echo "$@" >&2
20}
21
22die() {
23 ### Write an error message with the script name, and exit with status 1.
24 log "$0: fatal: $@"
25 exit 1
26}
27