Skip to content

Commit

Permalink
[stdlib] Start oil-polyfill.sh
Browse files Browse the repository at this point in the history
Just an idea for now.  Not used anywhere.
  • Loading branch information
Andy Chu committed Jul 27, 2019
1 parent 3e4a97f commit 1855f5c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
5 changes: 3 additions & 2 deletions design-docs/index.md
Expand Up @@ -15,12 +15,13 @@ Index of Oil Enhancement Proposals
- Status of command sub, assignments builtins, "bare" assignment, etc.
- [0005-oil-word-eval](0005-oil-word-eval.md)
- The "!QEFS" problem.
- `shopt -s oil-word-eval`
- `shopt -s oil-word-eval` or `shopt -s static-word-eval`
- no splitting
- static globbing
- are these separate options or not? maybe just make it one option
- keep `oil` out of the name so other shells can implement it
- [0006-splicing-arrays](0006-splicing-arrays.md)
- `__syntax__ oil-splice` -- syntax hcange @a @f(x, y) syntax
- `__syntax__ oil-splice` -- syntax change @a @f(x, y) syntax
- @(...) makes since in OSH but not Oil... doh. I guess it's not used, so you
can use it.
- also add argv in addition to repr? yeah I think that's a good addition
Expand Down
33 changes: 33 additions & 0 deletions stdlib/oil-polyfill.sh
@@ -0,0 +1,33 @@
# oil-polyfill.sh
#
# Portable shell for some of Oil's builtins.
#
# Usage:
# source oil-polyfill.sh
#
# TODO: Where to deploy this? I think we want versioned copies in
# ~/.local/lib/oil-0.7.0/stdlib/oil-polyfill.sh

sh-strict() {
### Turn on "legacy" shell strict modes.

# bash has this option, which is similar.
# use || true in case
# Actually we don't need this because of static-word-eval subsumes it?
#shopt -s nullglob 2>/dev/null || true

# POSIX
set -o errexit -o nounset -o pipefail
}

log() {
### Write a message to stderr.
echo "$@" 1>&2
}

die() {
### Write a message to stderr and exit failure.
log 'fatal:' "$@"
exit 1
}

0 comments on commit 1855f5c

Please sign in to comment.