linux - 为什么我不能从 setopt 中 grep zle?

标签 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!

最佳答案

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 正在关闭该选项。

关于linux - 为什么我不能从 setopt 中 grep zle?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33283140/

相关文章:

c++ - 将带有斜杠的 Unix 路径转换为 ​​Windows 路径

c - 多CPU作业的用户时间增加

python - 虚拟环境中的kivy,窗口提供程序错误(linux)

c++ - 应用程序终止后绑定(bind)错误 98 "Address in use"仍然存在

python - 无法从 python 命令提示符安装任何 python 包

linux - 如何获取终端属性

linux - 我怎样才能获得安全的系统级 oh-my-zsh 配置?

linux - 如何用sed正确检测和替换撇号(')?

linux - 在 Linux shell 脚本中解析

bash - 使用 verbose 和 xtrace (set -vx) 记录 bash 脚本并自定义 PS4