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.

···

---- Original Message ----
From: Haoqi Haoqi <axgle@126.com>
To: ruby-talk@ruby-lang.org (ruby-talk ML)
Sent: Tue, Nov 10, 2009, 19:52 PM
Subject: Is it a bug?exec "cd"

$ cat into.rb
exec "cd /tmp"
$ ruby into.rb
into.rb:1:in `exec': No such file or directory - cd /tmp (Errno::ENOENT)
from into.rb:1
---------------------
exec "cd anything" as the same result error.how to exec "cd"?thanks
--
Posted via http://www.ruby-forum.com/\.

Ah ?

~ $> which cd
/usr/bin/cd

Under Leopard

···

2009/11/11 wkm <wiktor@zanoccio.com>

'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.

>---- Original Message ----
>From: Haoqi Haoqi <axgle@126.com>
>To: ruby-talk@ruby-lang.org (ruby-talk ML)
>Sent: Tue, Nov 10, 2009, 19:52 PM
>Subject: Is it a bug?exec "cd"
>
>$ cat into.rb
>exec "cd /tmp"
>$ ruby into.rb
>into.rb:1:in `exec': No such file or directory - cd /tmp (Errno::ENOENT)
> from into.rb:1
>---------------------
>exec "cd anything" as the same result error.how to exec "cd"?thanks
>--
>Posted via http://www.ruby-forum.com/\.

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

···

On 2009-11-11, Benoit Daloze <eregontp@gmail.com> wrote:

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

Ah ?

~ $> which cd
/usr/bin/cd

Under Leopard

--
Copyright 2009, all wrongs reversed. Peter Seebach / usenet-nospam@seebs.net
| Seebs.Net <-- lawsuits, religion, and funny pictures
Fair game (Scientology) - Wikipedia <-- get educated!