1 | shopt
|
2 | ===
|
3 |
|
4 | 显示和设置shell操作选项
|
5 |
|
6 | ## 补充说明
|
7 |
|
8 | **shopt命令** 用于显示和设置shell中的行为选项,通过这些选项以增强shell易用性。shopt命令若不带任何参数选项,则可以显示所有可以设置的shell操作选项。
|
9 |
|
10 | ### 语法
|
11 |
|
12 | ```shell
|
13 | shopt(选项)(参数)
|
14 | ```
|
15 |
|
16 | ### 选项
|
17 |
|
18 | ```shell
|
19 | -s:激活指定的shell行为选项;
|
20 | -u:关闭指定的shell行为选项。
|
21 | ```
|
22 |
|
23 | ### 参数
|
24 |
|
25 | shell选项:指定要操作的shell选项。
|
26 |
|
27 | ### 实例
|
28 |
|
29 | 使用shopt命令显示当前所有可以设置的shell操作选项,输入如下命令:
|
30 |
|
31 | ```shell
|
32 | shopt #输出所有可以设置的shell操作选项
|
33 | autocd off
|
34 | cdable_vars off
|
35 | cdspell off
|
36 | checkhash off
|
37 | checkjobs off
|
38 | checkwinsize on
|
39 | cmdhist on
|
40 | compat31 off
|
41 | compat32 off
|
42 | compat40 off
|
43 | compat41 off
|
44 | compat42 off
|
45 | compat43 off
|
46 | complete_fullquote on
|
47 | direxpand off
|
48 | dirspell off
|
49 | dotglob off
|
50 | execfail off
|
51 | expand_aliases on
|
52 | extdebug off
|
53 | extglob off
|
54 | extquote on
|
55 | failglob off
|
56 | force_fignore on
|
57 | globasciiranges off
|
58 | globstar off
|
59 | gnu_errfmt off
|
60 | histappend on
|
61 | histreedit off
|
62 | histverify off
|
63 | hostcomplete on
|
64 | huponexit off
|
65 | inherit_errexit off
|
66 | interactive_comments on
|
67 | lastpipe off
|
68 | lithist off
|
69 | login_shell on
|
70 | mailwarn off
|
71 | no_empty_cmd_completion off
|
72 | nocaseglob off
|
73 | nocasematch off
|
74 | nullglob off
|
75 | progcomp on
|
76 | promptvars on
|
77 | restricted_shell off
|
78 | shift_verbose off
|
79 | sourcepath on
|
80 | syslog_history off
|
81 | xpg_echo off
|
82 | ```
|
83 |
|
84 | 如图上所示,选项"cdspell"的状态为"off",即关闭cd拼写检查选项。现在,可以使用shopt命令将其开启,输入如下命令:
|
85 |
|
86 | ```shell
|
87 | shopt -s cdspell #开启cd拼写检查
|
88 | ```
|
89 |
|
90 | 执行上面的命令后,该选项的状态将变为"on",即开启状态。可以再次通过该命令显示一下shell操作选项即可,输出信息如下:
|
91 |
|
92 | ```shell
|
93 | cdspell on #开启cdspell选项
|
94 | ```
|
95 |
|
96 | 用户可以通过实际执行cd命令检查该选项是否被成功开启。
|
97 |
|
98 |
|