为什么我不能从setopt中获益?

时间:2015-10-22 14:11:52

标签: linux shell unix zsh zsh-zle

我偶然发现了这件事,从那以后它一直在唠叨我:

% setopt
alwaystoend
autocd
autonamedirs
...
sharehistory
shinstdin
zle
%
% setopt | grep zle
# nothing printed
%
% setopt | cat -vet
alwaystoend$
autocd$
autonamedirs$
...
sharehistory$
shinstdin$
# no zle here!

正如您所看到的,grep无法检测到zle,并将setopt的输出汇总到cat,以便检测到任何不规则字符(而不是更有意义)也不显示zle

1 个答案:

答案 0 :(得分:5)

man zshzle
...
 If  the  ZLE option is set (which it is by default in interactive shells) and the shell input
       is attached to the terminal, the user is able to edit command lines.

由于您将setopt的输出传递给进程,因此shell将关闭命令行编辑。 (虽然本文档的这一行仅涉及附加到终端的shell输入,但它捕获了问题的本质。没有什么好笑的,只是shell正在关闭选项。