Why Sponsor Oils? | source | all docs for version 0.24.0 | all versions | oilshell.org
Warning: Work in progress! Leave feedback on Zulip or Github if you'd like this doc to be updated.
The OSH standard library runs under both OSH and bash. (YSH has a separate standard library.)
This doc briefly describes a few hundred lines of code, documented in the Oils reference:
I use shell as a quick / iterative / incremental development environment.
I use "task files" and write down everything I do, so I don't forget them.
They evolve and grew over time, but are still small.
: ${LIB_OSH=stdlib/osh} # to share with bash
source $LIB_OSH/bash-strict.sh
source $LIB_OSH/task-five.sh
test-foo() {
echo hi
}
task-five "$@"
Trivial functions I use all the time.
Catch errors.
Saves you some boilerplate.
Test framework without extra levels of quoting. Compare to git sharness.
nq-capture
nq-capture-2
nq-assert
May want to fold this into task-five.
$REPO_ROOT
?We commonly use this idiom:
REPO_ROOT=$(cd $(dirname $0)/..; pwd)
But there is no library for it, because there's no standard way for it. Other variants I've seen:
pwd -P # we use pwd
readlink -f $0
That is, there's not one way to do it when symlinks are involved.
Most of our scripts must be run from repo root, and there are no symlinks to them.
(Note that in OSH or YSH you can use $_this_dir
instead of $REPO_ROOT
, but
it's not available in bash.)