我正在从 Cygwin 运行 zsh。我的一个 shell 函数包含一个语句
rm -f somedir/*
(我想删除 somedir 中的所有非隐藏文件,但不是目录本身)。然而,我总是被问到:
zsh: sure you want to delete all the files in ... [yn]?
此消息的措辞(注意开头的“zsh:”)表明问题来自 zsh,而不是 rm。但是, rm 是一个外部命令:
$ type rm
rm is /usr/bin/rm
顺便说一句,如果我显式调用 rm 作为
$ command rm -f somedir/*
zsh 中是否有一些东西试图过于聪明?
最佳答案
看来RM_STAR_SILENT
是 不是 有效。
你可以做 setopt rmstarsilent
在命令行或 ~/.zshrc 中告诉 zsh 不确认 rm *
.
shell 选项 RM_STAR_SILENT
是:
Do not query the user before executing
rm *
orrm path/*
.
如果您想制作
setopt
仅在该 shell 函数中暂时起作用,您可以将它与 localoptions
结合使用像下面这样:my-test () {
setopt localoptions rmstarsilent
...
}
关于zsh - 为什么 rm -f 要求我在 zsh 上进行确认?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27988160/