The shopt builtin command

The shopt builtin manages shell options, a set of boolean (on/off) configuration variables that control the behaviour of the shell.

shopt [-pqsu] [-o] <OPTNAME...>

Note: Some of these options and other shell options can also be set with the set builtin.

OptionDescription
-oRestrict the values of <OPTNAME…> to only those also known by the set builtin
-pPrint all shell options and their current value. Default.
-qQuiet mode. Set exit code if named option is set. For multiple options: TRUE if all options are set, FALSE otherwise
-sEnable (set) the shell options named by <OPTNAME…> or list all enabled options if no names are given
-uDisabe (unset) the shell options named by <OPTNAME…> or list all disabled options if no names are given

As noted above, if only -s or -u are given without any option names, only the currently enabled (-s) or disabled (-u) options are printed.

When listing options, the exit code is TRUE (0), if all options are enabled, FALSE otherwise.

When setting/unsetting an option, the exit code is TRUE unless the named option doesn't exitst.

Enable the nullglob option:

shopt -s nullglob

The shopt command is not portable accross different shells.

This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information
You could leave a comment if you were logged in.
  • commands/builtin/shopt.txt
  • Last modified: 2010/04/07 19:43
  • (external edit)