2019-04-21 11:50:48 +08:00

31 lines
1.8 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<h1 id="shopt">shopt</h1>
<p>显示和设置shell操作选项</p>
<h2 id="补充说明">补充说明</h2>
<p><strong>shopt命令</strong> 用于显示和设置shell中的行为选项通过这些选项以增强shell易用性。shopt命令若不带任何参数选项则可以显示所有可以设置的shell操作选项。</p>
<h3 id="语法">语法</h3>
<pre><code class="language-bash">shopt(选项)(参数)</code></pre>
<h3 id="选项">选项</h3>
<pre><code class="language-bash">-s激活指定的shell行为选项
-u关闭指定的shell行为选项。</code></pre>
<h3 id="参数">参数</h3>
<p>shell选项指定要操作的shell选项。</p>
<h3 id="实例">实例</h3>
<p>使用shopt命令显示当前所有可以设置的shell操作选项输入如下命令</p>
<pre><code class="language-bash">shopt #输出所有可以设置的shell操作选项
cdable_vars off
cdspell off
checkhash off
checkwinsize on
cmdhist on
dotglob off
execfail off
expand_aliases on
extdebug off
...</code></pre>
<p>如图上所示选项“cdspell”的状态为“off”即关闭cd拼写检查选项。现在可以使用shopt命令将其开启输入如下命令</p>
<pre><code class="language-bash">shopt -s cdspell #开启cd拼写检查</code></pre>
<p>执行上面的命令后该选项的状态将变为“on”即开启状态。可以再次通过该命令显示一下shell操作选项即可输出信息如下</p>
<pre><code class="language-bash">cdspell on #开启cdspell选项</code></pre>
<p>用户可以通过实际执行cd命令检查该选项是否被成功开启。</p>
<!-- Linux命令行搜索引擎https://jaywcjlove.github.io/linux-command/ -->