TrumanWong

shopt

Display and set shell operation options

Supplementary instructions

shopt command is used to display and set behavioral options in the shell, and use these options to enhance the usability of the shell. If the shopt command does not take any parameter options, it can display all shell operation options that can be set.

grammar

shopt(options)(parameters)

Options

-s: Activate the specified shell behavior option;
-u: Turn off the specified shell behavior option.

Parameters

Shell options: Specify the shell options to operate.

Example

Use the shopt command to display all currently settable shell operation options. Enter the following command:

shopt #Output all shell operation options that can be set
autocdoff
cdable_vars off
cdspell off
checkhash off
checkjobs off
checkwinsize on
cmdhist on
compat31 off
compat32 off
compat40 off
compat41 off
compat42 off
compat43 off
complete_fullquote on
direexpand off
dirspell off
dotglob off
execfail off
expand_aliases on
extdebug off
extglob off
extquote on
failglob off
force_figure on
globasciiranges off
globstar off
gnu_errfmt off
histappend on
histreedit off
histverify off
hostcomplete on
huponexit off
inherit_errexit off
interactive_comments on
lastpipe off
lithist off
login_shell on
mailwarn off
no_empty_cmd_completion off
nocaseglob off
nocasematch off
nullglob off
progcomp on
promptvars on
restricted_shell off
shift_verbose off
sourcepath on
syslog_history off
xpg_echo off

As shown in the figure, the status of the option "cdspell" is "off", which means the cd spell check option is turned off. Now, you can use the shopt command to turn it on, enter the following command:

shopt -s cdspell #Enable cd spell check

After executing the above command, the status of this option will change to "on", that is, it is enabled. You can use this command again to display the shell operation options. The output information is as follows:

cdspell on #Turn on cdspell option

Users can check whether this option is successfully enabled by actually executing the cd command.