Re: Is it a bug?exec "cd"

‘cd’ isn’t actually a program. (typically; OS X seems to have it setup
as a super obscure shell script)

Note:

[wkm@zanoccio ~]$ which cd
/usr/bin/which: no cd in (/usr/kerberos/bin://bin:/usr/local/bin:/bin:/usr/bin:/home/wiktor/bin)

It’s one of the interpreted commands of the shell you’re using.

Ah ?

~ $> which cd
/usr/bin/cd

Under Leopard

2009/11/11 wkm [email protected]

On 2009-11-11, Benoit D. [email protected] wrote:

[Note: parts of this message were removed to make it a legal post.]

Ah ?

~ $> which cd
/usr/bin/cd

Under Leopard

builtin echo ${0##*/} | tr \[:upper:] \[:lower:] ${1+“$@”}

Doesn’t mean it’ll actually DO anything.

When you execute a command, your shell forks into a parent process (your
shell) and a child process. The child process then executes the
command.
The child process could, in theory, change its directory – but it
can’t
change the directory of the parent process:

$ pwd
/tmp
$ /usr/bin/cd /
$ pwd
/tmp

I have no idea why that command exists.

(I also have no idea why they use the ${1+“$@”} idiom, since it’s been
irrelevant on virtually everything for years, and certainly never made
any difference on any FreeBSD or Mac OS X shell.)

-s