例如:
$ ls -aF
./ ../ bin/
$ cd tin # with a tee, not bee
bin
$ pwd
/home/user/bin
Run Code Online (Sandbox Code Playgroud)
换句话说,cd猜测我真正的意思是cd bin,并成功(嗯?)相应地更改当前目录。我没有在Bash 参考手册man bash中找到这种行为的记录。
我希望 Bash 产生一个错误,向标准错误写入一些信息,如果没有找到与参数匹配的目录(考虑扩展) ,则保持当前目录不变。dir
供参考,
$ type cd
cd is a shell builtin
$ ps -p $$
PID TTY TIME CMD
46959 pts/8 00:00:00 bash
$ bash --version
GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version …Run Code Online (Sandbox Code Playgroud)