#Bash 的 shopt 命令
shopt [OPTION]... [OPT_NAME]...
功能
设置和取消设置 shell 选项。
类型
Bash 内置命令。
参数
OPTION- 选项:-o- 限制只能操作set -o定义的选项-p- 以命令行的格式打印每个 shell 选项及其状态-q- 不打印输出-s- 开启选项-u- 关闭选项
N- shell 的返回值为N;如果省略此参数,则以最后一个命令的返回值作为 shell 的返回值
#示例
查看选项
$ shopt
autocd off
assoc_expand_once off
cdable_vars off
cdspell off
...
开启和关闭选项
$ shopt -s autocd # 开启 autocd
$ shopt -u autocd # 关闭 autocd
#手册
shopt: shopt [-pqsu] [-o] [optname ...]
Set and unset shell options.
Change the setting of each shell option OPTNAME. Without any option
arguments, list each supplied OPTNAME, or all shell options if no
OPTNAMEs are given, with an indication of whether or not each is set.
Options:
-o restrict OPTNAMEs to those defined for use with `set -o'
-p print each shell option with an indication of its status
-q suppress output
-s enable (set) each OPTNAME
-u disable (unset) each OPTNAME
Exit Status:
Returns success if OPTNAME is enabled; fails if an invalid option is
given or OPTNAME is disabled.