How to get the cd shell-builtin to stop guessing?
32
votes
1
answer
2677
views
For example:
$ ls -aF
./ ../ bin/
$ cd tin # with a tee, not bee
bin
$ pwd
/home/user/bin
In other words,
cd
guesses that what I really meant was cd bin
, and *successfully* (huh?) changes the current directory accordingly. I do not find this behavior documented in man bash
or the [Bash Reference Manual](https://www.gnu.org/software/bash/manual/bash.html#Bourne-Shell-Builtins) .
I would like Bash to produce an error, write something informative to standard error, _and leave the current directory unchanged_ if no directory matching the dir
argument (accounting for [expansion](https://www.gnu.org/software/bash/manual/bash.html#Shell-Expansions)) is found.
FYI,
$ 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 3 or later
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ hostnamectl
Static hostname:
Icon name: computer-server
Chassis: server
Machine ID:
Boot ID:
Operating System: Red Hat Enterprise Linux
CPE OS Name: cpe:/o:redhat:enterprise_linux:7.9:GA:server
Kernel: Linux 3.10.0-1160.83.1.el7.x86_64
Architecture: x86-64
$ #DELETED: Static hostname, Machine ID, Boot ID
Asked by Ana Nimbus
(687 rep)
Feb 6, 2023, 06:42 PM
Last activity: Feb 7, 2023, 05:15 PM
Last activity: Feb 7, 2023, 05:15 PM