bash 命令行中 <TAB> 上的自动完成功能不起作用

Ole*_*nko 2 command-line bash terminal autocomplete

当我尝试在 bash 终端中使用自动完成功能时TAB,出现以下错误:

bash: !ref: unbound variable
bash: words[i]: unbound variable
Run Code Online (Sandbox Code Playgroud)

在命令中手动输入文件名非常烦人。那么,如何修复自动完成?


我用一些细节扩展了问题:

$ echo $SHELL
/bin/bash

$ echo $BASH
/bin/bash

$ bash --version
GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
Licesnse GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
...
Run Code Online (Sandbox Code Playgroud)

命令的getent passwd $USER输出以:/bin/bash/

Ole*_*nko 5

命令后问题已解决

$ set +u
Run Code Online (Sandbox Code Playgroud)