Bash Reference Manual:
Starting Bash with the --posix command-line option or executing ‘set -o posix’ while Bash is running will cause Bash to conform more closely to the POSIX standard by changing the behavior to match that specified by POSIX in areas where the Bash default differs.
For interactive use,
set -o | grep posix
...will emit something like:
posix off
For programmatic use, just enable or disable it (with set -o posix or set +o posix respectively) as suits your needs; there's little reason to ever check the prior value. That said, if you really want to, you can check SHELLOPTS:
case :$SHELLOPTS: in
*:posix:*) echo "POSIX mode enabled" ;;
*) echo "POSIX mode not enabled" ;;
esac
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With