Is there a minimal POSIX shell implementation for OS X? I like to write fairly portable shell scripts and want to catch as many incompatibilities or bashisms up front as I can. I'm not intending to replace the system /bin/sh.

/bin/sh on OS X 10.11.4 is GNU bash 3.2.57 or based on it.

$ /bin/sh --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin15)
Copyright (C) 2007 Free Software Foundation, Inc.

This is the same version string that /bin/bash reports even though the two files differ. Why is that by the way?

$ diff /bin/sh /bin/bash
Binary files /bin/sh and /bin/bash differ

Anyway, POSIX-compatibility mode bash still does some things that aren't required by the standard (and aren't de facto universal like local), e.g. this form of brace expansion.

$ echo {1..10}
1 2 3 4 5 6 7 8 9 10
  • 1
    Both dash and yash can be installed through Homebrew on macOS. Also /bin/sh on macOS would be sufficient for running POSIX scripts. The fact that it does brace expansions etc. does not mean it's not a POSIX shell. – Kusalananda Apr 12 at 9:36

MacPorts has dash, which is what Debian uses. For that and other choices, read Is there a minimally POSIX.2 compliant shell?, in which the answers point out that the standard is vague in places.

  • Homebrew also has a dash package. – Gregory Nisbet May 7 '16 at 23:08
  • As of 10.15, macOS ships with dash. – Gaelan Aug 13 at 2:17

Along with dash, there is also:

The Schily Bourne Shell was derived from the Bourne Shell sources from OpenSolaris.

Which is available on pkgin/pkgsrc.

Two options for pkgin:

  • The minimal POSIX compliant variant (pbosh)
  • The POSIX compliant extended variant (bosh)

Joyent provides macos pkgin binary packages


I haven't used it on a mac, but have used various variants of OpenSolaris.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.