Set shell options - toggle the value of variables which control optional shell behavior.

      shopt [-pqsu] [-o] [optname ...]

   -s     Enable (set) each optname.
   -u     Disable (unset) each optname.
   -q     Suppress normal output (quiet mode); the return status indicates whether the optname
          is set or unset.
   -o     Restrict the values of optname to be those defined for set -o.


          If set, an argument to the cd builtin command that is not a directory is assumed to be
          the name of a variable whose value is the directory to change to.
   cdspell If  set, minor errors in the spelling of a directory component in a cd command will be
          corrected.  The errors checked for are transposed characters, a missing character, and
          one character too many.  If a correction is found, the corrected file name is printed,
          and the command proceeds.  This option is only used by interactive shells.
          If set, bash checks that a command found in the hash table  exists  before  trying  to
          execute  it.  If a hashed command no longer exists, a normal path search is performed.
          If set, bash checks the window size after each command and, if necessary, updates  the
          values of LINES and COLUMNS.
   cmdhist If set, bash attempts to save all lines of a multiple-line command in the same history
           entry.  This allows easy re-editing of multi-line commands.
   dotglob If set, bash includes filenames beginning with a `.' in the results of pathname expansion.
          If  set, a non-interactive shell will not exit if it cannot execute the file specified
          as an argument to the exec builtin command.  An interactive shell  does  not  exit  if
          exec fails.
          If set, aliases are expanded as described above under ALIASES.  This option is enabled
          by default for interactive shells.
          If set, behavior intended for use by debuggers is enabled:
          1.     The -F option to the declare builtin displays the source  file  name  and  line
                 number corresponding to each function name supplied as an argument.
          2.     If the command run by the DEBUG trap returns a non-zero value, the next command
                 is skipped and not executed.
          3.     If the command run by the DEBUG trap returns a value of 2,  and  the  shell  is
                 executing in a subroutine (a shell function or a shell script executed by the .
                 or source builtins), a call to return is simulated.
          4.     BASH_ARGC and BASH_ARGV are updated as described in their descriptions above.
          5.     Function tracing is enabled:  command substitution, shell functions, and subshells
                 invoked with ( command ) inherit the DEBUG and RETURN traps.
          6.     Error tracing is enabled:  command substitution, shell functions, and subshells
                 invoked with ( command ) inherit the ERROR trap.
          If set, the extended pattern matching features described above under  Pathname Expansion
          are enabled.
          If  set,  $'string'  and $"string" quoting is performed within ${parameter} expansions
          enclosed in double quotes.  This option is enabled by default.
          If set, patterns which fail to match filenames during pathname expansion result in  an
          expansion error.
          If set, the suffixes specified by the FIGNORE shell variable cause words to be ignored
          when performing word completion even if the ignored words are the only possible completions.
          See  SHELL VARIABLES  for a description of FIGNORE.  This option is enabled by default.
          If set, shell error messages are written in the standard GNU error message format.
          If set, the history list is appended to the file named by the value of the HISTFILE
          variable when the shell exits, rather than overwriting the file.
          If  set, and readline is being used, a user is given the opportunity to re-edit a
          failed history substitution.
          If set, and readline is being used, the results of history substitution are not immediately
          passed  to  the shell parser.  Instead, the resulting line is loaded into the
          readline editing buffer, allowing further modification.
          If set, and readline is being used, bash will attempt to perform  hostname  completion
          when  a  word containing a @ is being completed (see Completing under READLINE).
          This is enabled by default.
          If set, bash will send SIGHUP to all jobs when an interactive login shell exits.
          If set, allow a word beginning with # to cause that word and all remaining  characters
          on  that line to be ignored in an interactive shell (see COMMENTS).  This option
          is enabled by default.
   lithist If set, and the cmdhist option is enabled, multi-line commands are saved to  the  his-tory history
          tory with embedded newlines rather than using semicolon separators where possible.
          The  shell  sets this option if it is started as a login shell (see INVOCATION).
          The value may not be changed.
          If set, and a file that bash is checking for mail has been  accessed  since  the  last
          time  it was checked, the message ``The mail in mailfile has been read'' is displayed.
          If set, and readline is being used, bash will not attempt to search the PATH for  pos-sible possible
          sible completions when completion is attempted on an empty line.
          If  set, bash matches filenames in a case-insensitive fashion when performing pathname
          expansion (see Pathname Expansion).
          If set, bash matches patterns in a case-insensitive fashion when  performing  matching
          while executing case or [[ conditional commands.
          If  set,  bash  allows patterns which match no files (see Pathname Expansion above) to
          expand to a null string, rather than themselves.
          If set, the programmable completion facilities (see Programmable Completion above) are
          enabled.  This option is enabled by default.
          If  set,  prompt strings undergo parameter expansion, command substitution, arithmetic
          expansion, and quote removal after being expanded as  described  in  PROMPTING  above.
          This option is enabled by default.
          The  shell  sets this option if it is started in restricted mode (see RESTRICTED SHELL
          below).  The value may not be changed.  This is not reset when the startup  files  are
          executed, allowing the startup files to discover whether or not a shell is restricted.
          If set, the shift builtin prints an error message when the  shift  count  exceeds  the
          number of positional parameters.
          If set, the source (.) builtin uses the value of PATH to find the directory containing
          the file supplied as an argument.  This option is enabled by default.
          If set, the echo builtin expands backslash-escape sequences by default.

With no options, or with the -p option, a list of all settable options is displayed, with an indication of whether or not each is set.

The -p option causes output to be displayed in a form that may be reused as input.

If either -s or -u is used with no optname arguments, the display is limited to those options which are set or unset, respectively. Unless otherwise noted, the shopt options are disabled (unset) by default.

The return status when listing options is zero if all optnames are enabled, non-zero otherwise.
If multiple optname arguments are given with -q, the return status is zero if all optnames are enabled; non-zero otherwise.
When setting or unsetting options, the return status is zero unless an optname is not a valid shell option.

shopt is a bash builtin command.

“Try to be like the turtle - at ease in your own shell” ~ Bill Copeland

Related macOS commands

set - Set a shell variable = value
unset - Remove variable or function names.

Copyright © 1999-2024
Some rights reserved