Why Sponsor Oils? | blog | oilshell.org
This is the latest release of Oil, a Unix shell:
Please try it on your shell scripts and report bugs! To build and run it, follow the instructions in INSTALL.txt. The wiki has more tips on How To Test OSH.
This release has two major themes:
The two themes strongly relate to prior blog topics. Before diving into details, here is some higher-level context.
Shell is both an user interface and a programming language, and I've addressed this issue a few times.
There's no reason a shell can't do well in both respects — it's just a lot of work. For reference, bash itself is ~142K lines of code. Its companion GNU readline, which provides a minimal experienced compared to say fish, is ~34K lines of code.
ble.sh
A few weeks ago, Danilo Spinella pointed out the Bash Line Editor project, which I'll refer to as ble.sh from now on.
It gives you a fish-like interactive experience in bash. The astonishing thing is that it's written in bash. I'm no stranger to big shell scripts, both batch and interactive, but this surprised me!
I'll write more about ble.sh in the future, but here are some links:
I'm not sure if Oil will be able to run ble.sh, but this release is major progress toward doing so.
If it eventually does, that will show an unexpected benefit of Oil's compatibility with bash, which has been a tremendous effort.
The other major theme is the continuous build at travis-ci.oilshell.org.
Its source code lives in the new services/ directory, and I started calling it "Toil". Besides being a useful tool, its implementation demonstrates techniques that I want to write about under #shell-the-good-parts:
ssh
with Bernstein chaining, scp
,
zip
, etc.
main()
; I reuse as many Unix tools as
possible; and write my own where there are gaps.x64
. When it does, this
will be more convincing.In short, I use the Unix philosophy of reusing programs written in different languages as shell "libraries".
Now that we've reviewed how Oil's infrastructure uses the Unix philosophy, here are the detail of this release.
This section summarizes the full changelog, starting with external contributors:
Travis A. Everett fixed spec tests to make them more portable, e.g. to a Nix environment.
Koichi Murase, author of ble.sh, made many changes necessary to run it.
declare/readonly/export -p
to print variables in a form that
eval
understands. ble.sh uses this idiom to save and restore
state.printf
language, including %()T
for
timestamps and %*s
and %.*s
for user-defined width and precision.3>&-
to close a descriptor and 3>&1-
to move a descriptor. (These
features are useful for compatibility, but Avoid Directly Manipulating
File Descriptors in Shell in general.){varname}>out
to have the shell choose a file descriptor and store it in
a variable. This needs a better syntax in Oil.${@:i:j}
.
Surprisingly, ${@:0}
gives you more items than ${@}
has!BASH_LINENO
/ FUNCNAME
can be referenced as scalars or arrays, like
BASH_SOURCE
.${!prefix@}
construct.read -d
, mapfile
/ readarray
, and dynamic
RHS in arithmetic.In addition to many other changes, I made the following changes related to ble.sh:
read -d
. (It's useful to have failing spec tests before
implementing a feature. I merge changes that only include failing tests
because they clarify what Oil should do.)test -v
and test-k
.F_DUPFD
ensures that a shell's own descriptors (e.g. to implement source
)
don't collide with the program's descriptors.declare -A dict=()
, which is now documented in
Quirks.$(( a ))
when a
doesn't look
like an integer.eval
and trap
to accept --
.set -o emacs
in interactive mode like bash does.shopt -s parse_ignored
for bash
compatibility.Other:
printf %b
, which allows the argument to use backslash escapes like
echo -e
.GammaFn
.The docs are still in their early stages, but I've updated a few of them:
fork()
.On the Wiki:
Reminder: There are threads on oilshell.zulipchat.com about almost every topic in this post, and more:
If you're a bash user who wants a fish-like experience, please try ble.sh and let me know what you think. It took me less than 20 seconds to install and try. The instructions are at akinomyoga/ble.sh.
Let's compare this release with the previous one, version 0.8.pre2, which I reported detailed metrics on earlier this month.
The features and bug fixes for ble.sh
caused many more spec tests to pass.
And we have more failing spec tests to guide future work.
A few more Oil spec tests fail because I made the test framework
stricter. If there's a Python traceback on stderr
, the test fails no matter
what. This surfaced a few bugs which I quickly fixed, but others remain.
I'm happy that all the new features fit in ~400 new significant lines of code:
... and ~600 new physical lines of code:
The translation to C++ still works, but it didn't change in this release. There was no meaningful change in parser performance:
Or the size of the binary:
osh_eval
is 663,792 bytes of native code (under GCC)osh_eval
is 667,888 bytes of native code (under GCC)#674 | enforce upper limit on hard-coded file descriptors |
#664 | error message for $(( a )) doesn't have location |
#662 | trap doesn't accept / ignore -- |
#661 | declare -A dict=() not allowed in Oil |
#659 | set -o vi and emacs should be have differently while interactive |
#650 | Implement printf %*s and %.*s |
#637 | 'type' says control flow like 'return' is a builtin, but it's not in Oil |
#620 | disallowing redirects on control flow too strict by default (Run ble.sh) |
#537 | Implement `test -v` and `test -k` |
#357 | implement printf %b to do backslash escaping |
#356 | Implement read -d and other options |