bash returns wrong error code when changing to nonexisting directory
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
bash (Ubuntu) |
Triaged
|
Low
|
neelima parakala |
Bug Description
Binary package hint: bash
When removing current directory and then doing a cd . bash reports sucess when invoked as /bin/bash but reports failure when invoked as /bin/sh. IMO it should report failure in both cases.
ankpelle[~]$ /bin/bash
ankpelle[~]$ mkdir /scratch/kalle
ankpelle[~]$ cd /scratch/kalle/
ankpelle[kalle]$ rmdir /scratch/kalle
ankpelle[kalle]$ cd .
cd: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
ankpelle[.]$ echo $?
0
ankpelle[.]$ pwd
/scratch/kalle/.
ankpelle[.]$ exit
exit
sh-3.2$ mkdir /scratch/kalle
sh-3.2$ cd /scratch/kalle/
sh-3.2$ rmdir /scratch/kalle
sh-3.2$ cd .
sh: cd: .: No such file or directory
sh-3.2$ echo $?
1
sh-3.2$ pwd
pwd: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
sh-3.2$ ls -l /bin/sh
lrwxrwxrwx 1 root root 4 2007-02-16 13:33 /bin/sh -> bash
sh-3.2$ exit
Changed in bash: | |
assignee: | nobody → chris-vault5 |
importance: | Undecided → Low |
Changed in bash (Ubuntu): | |
assignee: | Chris Rose (chris-vault5) → nobody |
status: | Incomplete → Triaged |
Changed in bash (Ubuntu): | |
assignee: | nobody → neelima parakala (lissomlilyneelu) |
Thank you for your bug report. In this instance, cd returns success because it has actually chdir()'d, the problem comes when bash can't realise the path that it is actually in.
You can see discussion of this problem here:
http:// groups. google. co.uk/group/ gnu.bash. bug/browse_ thread/ thread/ ad71fec768f10fa 6/a6dfb11dc2e87 403
It isn't clear if it is actually considred a bug or not and if it is, if bash is the cause. I've marked this as needs info because someone with more clue than myself needs to work out where the bug actually lies.