'cd' does 'pwd' with relative path but not with absolute path - documented?

Chris Green cl at isbd.net
Fri Jul 3 08:28:54 UTC 2020


I have only recently noticed that when running bash in a terminal 'cd'
acts differently for relative and absolute paths.

If you do a cd to an absolute path it outputs nothing but if you cd to
a relative path it outputs (i.e. does a pwd) the path after changing
directory.

For example:-

    chris$ cd
    chris$ cd /tmp
    chris$ cd scans
    /tmp/scans
    chris$ 

Note that the cd without a parameter does cd $HOME and $HOME is an
absolute path so follows the same logic.

Is this documented anywhere? cd is a bash builtin but I can't see
anything about it in the bash man pages.  Also, can one change this
to, for example, always reporting the destination directory or never
reporting it.

-- 
Chris Green




More information about the ubuntu-users mailing list