1. 用 set 命令。
set -o option 是把 option 选项打开; set +o opton 则是关掉。
命令行输入 help set会列出可用的选项。
比如, set -f 或者 set -o noglob 会打开禁用文件名扩展的功能, set +f 或者 set +o noglob则是关闭它。
$ ls
file1 file2
$ set -o noglob
$ ls *
ls: cannot access *: No such file or directory
$ set +o noglob
$ ls *
file1 file2
另外一个是 shopt 命令。
执行 shopt ?
会列出当前的配置:
$ shopt ?
autocd off
cdable_vars off
cdspell off
checkhash off
checkjobs off
checkwinsize on
cmdhist on
compat31 off
compat32 off
compat40 off
compat41 off
direxpand off
dirspell off
dotglob off
execfail off
expand_aliases on
extdebug off
extglob on
extquote on
failglob off
force_fignore on
globstar off
gnu_errfmt off
histappend on
histreedit off
histverify off
hostcomplete off
huponexit off
interactive_comments on
lastpipe off
lithist off
login_shell off
mailwarn off
no_empty_cmd_completion off
nocaseglob off
nocasematch off
nullglob on
progcomp on
promptvars on
restricted_shell off
shift_verbose off
sourcepath on
xpg_echo off
shopt -s option 设置 option选项, shopt -u option 则是关闭
shopt option 给出这个 option的状态:
$ shopt extglob
extglob on