From: Beej Jorgensen on
Man-wai Chang ToDie (33.6k) <toylet.toylet(a)gmail.com> wrote:
>I meant... the cd command itself converts the dir name into inode
>number internally, right? I would be surprised if it's not....

Very internally. inodes are quite deep down, and cd really doesn't have
to know about them.

Each process has a current working directory, which can be obtained from
a call to getcwd(). This includes the bash shell, or whatever shell
you're running. It changes its working directory by calling the system
call chdir() when you issue a "cd" command.

As such, cd isn't a program:

$ which cd
which: no cd in ( ... )

and it makes no sense to have it be a program. Because if the shell ran
the external "cd" program, and cd changed its working directory, the
shell's working directory would remain unchanged.

So what happens is (basically with glossy details):

1. You type "cd foo"
2. The shell executes chdir("foo")
3. The system call chdir() runs the internal namei algorithm to convert
the path to an inode.
4. chdir() sets this process's current working directory to namei's
result.

In bash, you can type "help cd" or "man bash" for the options, since
it's an internal bash command. I'd expect the options to widely vary
from shell to shell.

$ help cd
cd: cd [-L|-P] [dir]

%cd -h
Usage: cd [-plvn][-|<dir>].

-Beej

From: Bit Twister on
On Tue, 06 May 2008 20:20:45 +0800, Man-wai Chang ToDie (33.6k) wrote:
>
> Oh no... where are cd' options?

Install a distributions which has man pages. :)

http://man.he.net/
http://www.win.tue.nl/~aeb/linux/man/
http://www.freebsd.org/cgi/man.cgi
http://netbsd.gw.com/cgi-bin/man-cgi
http://www.openbsd.org/cgi-bin/man.cgi
From: pk on
On Tuesday 6 May 2008 14:36, Bit Twister wrote:

> On Tue, 06 May 2008 20:20:45 +0800, Man-wai Chang ToDie (33.6k) wrote:
>>
>> Oh no... where are cd' options?
>
> Install a distributions which has man pages. :)

If he's using bash, then the options are in man bash, since cd is builtin in
bash. However, my system does have a proper man page for cd too.

From: Man-wai Chang ToDie (33.6k) on
> If he's using bash, then the options are in man bash, since cd is builtin in
> bash. However, my system does have a proper man page for cd too.

Saw....

--
@~@ Might, Courage, Vision, SINCERITY.
/ v \ Simplicity is Beauty! May the Force and Farce be with you!
/( _ )\ (Xubuntu 7.10) Linux 2.6.25.1
^ ^ 21:49:01 up 3 days 2:14 3 users load average: 2.16 2.20 2.13
�� �� (CSSA):
http://www.swd.gov.hk/tc/index/site_pubsvc/page_socsecu/sub_addressesa/
From: Man-wai Chang ToDie (33.6k) on
> If he's using bash, then the options are in man bash, since cd is builtin in
> bash. However, my system does have a proper man page for cd too.

How could I cd into a folder using its inode number?

--
@~@ Might, Courage, Vision, SINCERITY.
/ v \ Simplicity is Beauty! May the Force and Farce be with you!
/( _ )\ (Xubuntu 7.10) Linux 2.6.25.1
^ ^ 21:50:01 up 3 days 2:15 2 users load average: 2.06 2.16 2.12
�� �� (CSSA):
http://www.swd.gov.hk/tc/index/site_pubsvc/page_socsecu/sub_addressesa/
 |  Next  |  Last
Pages: 1 2
Prev: Firefox
Next: Proble with LDAP