shellposixdash-shell

explicit posix mode in dash


I usually work on CentOS 7 and a standard(?, /bin/sh automatically installed) shell handles an option set -o posix.

but the option does not work a shell (/bin/sh) in Xubuntu.

It says "no such option: posix", when I try set -o posix.

What is the alternative option in dash?


Solution

  • With Red Hat-based distributions, such as CentOS 7, /bin/sh is a symbolic link to /bin/bash. set -o posix is a shell option that is used by Bash to limit its behaviour so that it’s (more) POSIX compatible.

    With Debian-based distributions, such as Xubuntu, /bin/sh is a symbolic link to /bin/dash. As the tag wiki for states, it’s already POSIX compliant. Hence, there’s no need for an explicit option to change its behaviour.