OILS / stdlib / oil-polyfill.sh View on Github | oilshell.org

41 lines, 10 significant
1# oil-polyfill.sh
2#
3# Portable shell for some of Oil's builtins.
4#
5# Usage:
6# source oil-polyfill.sh
7#
8# TODO: Where to deploy this? I think we want versioned copies in
9# ~/.local/lib/oil-0.7.0/stdlib/oil-polyfill.sh
10
11sh-strict() {
12 ### Turn on "legacy" shell strict modes.
13
14 # bash has this option, which is similar.
15 # use || true in case
16 # Actually we don't need this because of static-word-eval subsumes it?
17 #shopt -s nullglob 2>/dev/null || true
18
19 # POSIX
20 set -o errexit -o nounset -o pipefail
21}
22
23log() {
24 ### Write a message to stderr.
25 echo "$@" 1>&2
26}
27
28die() {
29 ### Write a message to stderr and exit failure.
30 log 'fatal:' "$@"
31 exit 1
32}
33
34# Idea: from Soil, to fix Bernstein chaining.
35#
36# ssh $USER@$HOST "$(printf '%q ' "$@")"
37#
38# Also need one for scp.
39
40# Idea: from tea/run.sh, exit 255 for xargs
41# Does this need run --assign-status, or can it be POSIX shell?