Strange behaviour of the "cd" command

Ken D'Ambrosio ken at jots.org
Tue Jul 11 17:39:21 UTC 2017


On 2017-07-11 12:17, Xen wrote:

> Or maybe it has all kinds of speed-up features that you might have 
> triggered.

Not even sure what you mean by "speed-up" feature, especially when it 
violates pretty dramatically the "least astonishment" principle.

1) How *would* you cd to a directory preceded by a . using relative 
nomenclature if not the one already described?
2) Why would you be able to cd into it using absolute nomenclature?
3) It completely violates non-built-in nomenclature, such as that used 
by "ls" or even "rmdir" and "mkdir"
4) Lastly, it clearly violates safe-use nomenclature:

$ pwd
/tmp
$ mkdir -p one/two
$ mkdir .three
$ cd one/two
$ cd ../../.three
ksh: cd: /tmp/three: [No such file or directory]
$ mkdir ../../three
$ cd ../../.three
$ pwd
/tmp/three

Et voila!  Suddenly, you're not in the directory you explicitly 
specified on your CLI.  That's a Bad Thing(tm).  I have a really hard 
time believing someone would modify "."'s funcionality *while part of a 
pathname*.  That way lies madness and deleted files.

$.02,

-Ken




More information about the ubuntu-users mailing list