-bash: !": 事件未找到
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26443880/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
-bash: !": event not found
提问by Michel Frechette
How do I fix this bash terminal? Why would the '!' suddenly be a problem and the need for quotation marks are no longer seem to be necessary to produce the string. Did I break something? If so how do I reset it to factory setting? I'm sure it was working properly yesterday
如何修复这个 bash 终端?为什么会“!” 突然成为一个问题,似乎不再需要引号来产生字符串。我是不是弄坏了什么东西?如果是,我如何将其重置为出厂设置?我确定它昨天工作正常
Last login: Sat Oct 18 15:30:48 on ttys001
Michels-MacBook-Pro:~ michelfrechette$ echo "hello, world!"
-bash: !": event not found
Michels-MacBook-Pro:~ michelfrechette$ echo hello, world
hello, world
Michels-MacBook-Pro:~ michelfrechette$ echo "hello, world"
hello, world
-bash: !": event not found
, this is curious.
-bash: !": event not found
,这很好奇。
回答by Charles Duffy
Running
跑步
set +H
will turn off the offending (history expansion) functionality in its entirety. Putting this in your ~/.bashrc
is a common practice.
将完全关闭违规(历史扩展)功能。把它放在你的身上~/.bashrc
是一种常见的做法。
Alternately, you can modify the histchars
variable to change the characters used to trigger history expansion (by default, !
), quick substitution (by default, ^
) and comments (by default, #
).
或者,您可以修改histchars
变量以更改用于触发历史扩展(默认为!
)、快速替换(默认为^
)和注释(默认为#
)的字符。
As yet another option, using single- rather than double-quotes avoids triggering the shell feature in question.
作为另一种选择,使用单引号而不是双引号可以避免触发相关的 shell 功能。