← Back to context

Comment by jchw

1 year ago

AFAIK, enabling POSIXLY_CORRECT doesn't get rid of any functionality. It changes some very subtle behaviors, such as the way certain argument parsing edge cases would be handled.

Anyway, I think this is somewhat a non-issue: even if bash doesn't fully comply with POSIX standards by default, it should still be possible to be POSIX compliant by delivering a compliant shell in the right place. Though this does make me wonder if there's anything in POSIX that would require the user's default login shell to be POSIX-compliant, Bourne shell compatible. Probably not, right? After all, macOS had been using bash for ages with no issues complying.

Nope nope nope.

You can see this in a script by defining:

  alias p=printf

Then try to use it with bash. If bash is running as #!/bin/sh, then it will work, because bash is forced into POSIX mode.

However, if the script is running as #!/bin/bash, then you will be in the '80s behavior, and it will fail.

Try it.

  • Bash isn't part of GNU coreutils.

    • I realize that, but I'm illustrating that POSIX.2 required a retrofit to bash, and probably required similar adjustments to the rest of userland, including coreutils.

      5 replies →