Skip to content

How To Test OSH

andychu edited this page Mar 26, 2020 · 22 revisions
Clone this wiki locally

If anything on this page is unclear, or you can't get it to work, feel free to send feedback on Github or start a thread on (log in with Github). More: Where To Send Feedback.

Also, feel free to edit the page with tips.

It would be great to add more scripts to Shell Programs That Run Under OSH.

Related: What Is Expected to Run Under OSH


Run ./configure, make, sudo ./install -- as described in the INSTALL.txt.


  • osh behaves just like /bin/bash:
    • osh -c 'echo hi'
    • osh
    • Or source within OSH.
    • etc.
  • The startup file is ~/.config/oil/oshrc
    • Make an ~/.oshrc symlink if that gets annoying to type.
  • Our temporary fork of the bash-completion project has some required features:

Useful Features for Testing

(1) Run osh with OSH_HIJACK_SHEBANG=<shell>


OSH_HIJACK_SHEBANG=$(which osh) osh -c 'echo hi; ./'

# Now will be excuted with OSH if its shebang looks like #!/bin/sh or #!/bin/bash.

(2) Run OSH with --debug-file FIFO. The argument is a file to write log messages to. It's useful to make it a FIFO / named pipe.

In tmux, I open up a shell with --debug-file tmp/debug on the LEFT, and a shell that cats the debug stream on the RIGHT.


$ mkfifo _tmp/debug  # named pipe

$ osh --debug-file _tmp/debug    # do this on the LEFT.  
                                 # You can also set -x and PS4='+$LINENO '
                                 # Type commands here like 'source testdata/completion/git'.
$ cat _tmp/debug                 # do this on the RIGHT.

Also see Debugging Completion Scripts

Channels for Feedbak

My oshrc file

PS1='[osh] \h \w\$ '  # so I know I'm running OSH


# Load git completion plugin.
. $oil_repo/testdata/completion/git

# Load my bashrc, which I have patched.  I use the absence of $BASH_VERSION to test for OSH.
. ~/.bashrc

The .bashrc loads my own custom completions, which fall back on the temporary fork of bash-completion (URL and branch above). Example:

. ~/git/oilshell/bash-completion/osh_completion` # this script is a modified version of bash_completion