Skip to content
andychu edited this page Oct 30, 2024 · 11 revisions

(work in progress)

NEWER: Gradually Upgrading Shell to YSH (TODO: Consolidate these)

Test Whether Your Scripts Parse

If you have a big repo of shell scripts, a quick and easy test for "smoke test" for compatibility is:

find . -name '*.sh' | xargs -- osh -n

This will attempt to parse all the files. (TODO: handle failure, etc.)

Run your scripts

osh behaves like any other shell, so this is as simple as

osh myscript.sh

Enable Strict Mode

If you want more errors out of OSH, put this at the top of your shell scripts:

shopt -s strict:all

To remain compatible with other shells, suppress stderr and ignore failure if this option doesn't exist:

shopt -s strict:all 2>/dev/null || true

Do You Have Tests?

In some settings, you can just change your shebang lines from #!/bin/bash to #!/usr/bin/env osh, and "see what happens".

In other settings, you might want to write tests first. Then run the tests with both bash and osh.

I filed issue #297 Runs the bats test framework because bats appears to be pretty popular. (Although I'd also like OSH to have some simpler test framework builtin. That is, some simple "batteries" should be included.)

Having Problems?

Start a thread on #oil-discuss on https://oilshell.zulipchat.com/ (log in with Github).

Clone this wiki locally