Set and Shopt - Why Two?

As far as I know, the set -o options are the ones that are inherited from other Bourne-style shells (mostly ksh), and the shopt options are the ones that are specific to bash. There's no logic that I know of.


The difference is in the changed environment variable used by bash. Setting with the set command results in $SHELLOPTS. Setting with the shopt command results in $BASHOPTS.


  • set is POSIX 7: set - set or unset options and positional parameters | pubs.opengroup.org

  • shopt is not: Shell & Utilities: Detailed Toc | pubs.opengroup.org

Probably linked to the history mentioned by @Gilles.