blog | oilshell.org

OSH 0.4 - A Shell Language That's Nearly Feature Complete

I've released version 0.4 of OSH, a bash-compatible shell. If you're new to the project, see Why Create a New Shell?.

To build and run it, follow the instructions in INSTALL.txt. Please try it on your shell scripts and report bugs!

This release contains many new features and bug fixes that allow OSH to run real shell programs. Read on for details.

Caveats

As I've warned in all past releases, OSH is too big and too slow. I wrote it in an abstract style, focusing on the language's semantics over performance.

OSH is not yet a good interactive shell. Many interactive features are missing.

This is why I say the language is nearly feature-complete, as opposed to the "shell" or "implementation". Those aspects of the project still need a lot of work, and are addressed in the Why? post.

Changes

However, since OSH 0.4 can run a diverse group of large programs, it's a big milestone!

The post Success with Aboriginal, Alpine, and Debian describes most of the changes, including:

An overhaul of word splitting and evaluation , with many bug fixes.

, with many bug fixes. The read builtin also respects $IFS , as well as -r .

builtin also respects , as well as . Implemented set -o xtrace and related environment variables.

and related environment variables. Two types of C-escaped strings: echo -e and $'

' .

and . Process substitution.

Adjust errexit behavior to match bash and busybox ash. Add set -o strict-errexit for more rational behavior.

behavior to match bash and busybox ash. Add for more rational behavior. Miscellaneous bug fixes, which you can see in the full changelog.

In addition to shell scripts from three Linux distros, I also fixed enough bugs to run the shell-script-library project by Stephen Reay.

More features:

The dirs builtin is essentially complete.

builtin is essentially complete. An initial cut of of the trap builtin. It supports the EXIT trap and signals handlers like SIGTERM . A full implementation may have to wait until OSH no longer uses Python.

builtin. It supports the trap and signals handlers like . A full implementation may have to wait until OSH no longer uses Python. declare respects -f , -x , and -r .

respects , , and . C-style for loops.

Build platforms:

I was able to build and run OSH in a Gentoo chroot. However, it might not work with all versions of Gentoo. File a bug if you run into problems.

The binary is slightly smaller. See the Appendix on project metrics.

Contributors

timetoplatypus finished implementing the dirs builtin.

finished implementing the builtin. cclauss added support for Travis continuous builds, and fixed bugs caught by flake8.

Bug Reports that led to changes:

Travis B. Hartwell: the trap builtin. declare -f -x -r

puppeh : C-style for loops.

: C-style for loops. Stephen Reay: shared his shell-script-library project with me. In the future, it may show up as a runtime benchmark for OSH.

As usual, the full changelog has details.

What's Next?

As for the blog, I plan to write part two of the FAQ, since there were many questions about Oil on Hacker News.

As for the code: Since OSH can run many shell programs, I won't be actively trying new programs in the next release cycle.

However, I still plan to implement features and fix bugs on demand. Please try OSH on your shell programs, and report bugs!

Instead, I plan to work on these thigns:

(a) A "carrot" for Oil, i.e. a feature that existing shells don't have. Ideas:

Static analysis to figure out what binaries a shell script uses.

to figure out what binaries a shell script uses. App Bundles for deploying Oil itself, shell scripts, and associated binaries.

for deploying Oil itself, shell scripts, and associated binaries. Dumping the interpreter state for crash reports.

(b) Prototyping and documenting the Oil language.

(c) Making the Oil binary smaller.

Appendix: Project Metrics

The new features and bug fixes are reflected in spec test stats:

OSH 0.3 spec tests: 877 total tests, 709 passing, 121 failing

total tests, passing, failing OSH 0.4 spec tests: 1,003 total tests, 839 passing, 116 failing

Despite all the new features, the core interpreter has only grown by ~1500 lines:

In addition, I took the first steps toward slimming down the app bundle:

OSH 0.3 native deps: 174,506 lines of C from CPython

lines of C from CPython OSH 0.4 native deps: 165,127 lines of C from CPython

As part of my plan to break Oil's CPython dependency without rewriting the whole program, I'm counting lines in different ways:

parser.txt: A breakdown of the front end.

runtime.txt: A breakdown of the runtime.

oil-osh-cloc.txt: OSH is just 8,727 lines if you exclude comments and blank lines!

Although OSH is still too big and too slow, it's going in the right direction. The binary has more features than ever, and it's smaller than ever.