|
|
|
|
|
by kazinator
3031 days ago
|
|
> The cd builtin is invoked as part of the Bash shell. > The Bash shell invokes the chdir function. Nope! Not quite. Bash: ~$ ls -ld foo
lrwxrwxrwx 1 kaz kaz 4 Mar 1 6:50 foo -> /etc
~$ cd foo
~/foo$ pwd
/home/kaz/foo
~/foo$ cd ..
~$ pwd
/home/kaz
Raw chdir and getcwd syscalls: $ pwd
/home/kaz
$ txr
This is the TXR Lisp interactive listener of TXR 190.
Quit with :quit or Ctrl-D on empty line. Ctrl-X ? for cheatsheet.
1> (chdir "foo")
t
2> (pwd)
"/etc"
3> (chdir "..")
t
4> (pwd)
"/"
See the difference? While of course the shell will invoke chdir, it has its own idea of a current working directory, and translates the argument of cd to something else. For instance cd .. doesn't translate to (chdir ".."). |
|
So the article does point out that CD isn't a direct alias for chdir