为什么“!!” 快捷方式无法执行之前运行的命令?

Bul*_* M. 14 command-line bash bash-history

最近我在我的终端打字

username:~$ !!
Run Code Online (Sandbox Code Playgroud)

并从bash得到错误:

bash: !!: command not found
Run Code Online (Sandbox Code Playgroud)

同时,它在超级用户下完成时成功。

我调查了我用户的 PATH 内容,没有发现任何可疑之处:

/home/username/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
Run Code Online (Sandbox Code Playgroud)

这是输出:

username:~$ history | tail
1993  date
1994  cal
1995  vcal
1996  uptime
1997  uname
1998  uptime
1999  uname
2000  uptime
2001  uname
2002  history | tail
Run Code Online (Sandbox Code Playgroud)

其他:

username:~$ echo foo
foo
username:~$ !!
bash: !!: command not found
Run Code Online (Sandbox Code Playgroud)

mur*_*uru 23

历史扩展可能被禁用:

$ echo foo
foo
$ !!
echo foo
foo
$ set +o histexpand
$ set -o | grep hist
histexpand      off
history         on
$ echo foo
foo
$ !!
bash: !!: command not found
Run Code Online (Sandbox Code Playgroud)

尝试set -Hset -o histexpand