* stracing pwd
@ 2004-06-19 15:29 David Eduardo Gómez Noguera
2004-06-19 16:13 ` Christoph Bussenius
0 siblings, 1 reply; 2+ messages in thread
From: David Eduardo Gómez Noguera @ 2004-06-19 15:29 UTC (permalink / raw)
To: Linux C Programming
Hellow. This just striked me.
I wondered how pwd works, I entered a linked directory, and pwd gives me
the link.
when I tried pwd -h (wrong argument) I saw there are two possible
arguments
I have
/usr/src/linux-2.6.7
/usr/src/linux -> /usr/src/linux-2.6.7
under /usr/src/linux,
pwd prints /usr/src/linux
pwd -L too
pwd -P prints /usr/src/linux-2.6.7
but an strace always shows the same
write(1, "/usr/src/linux-2.6.7\n", 21/usr/src/linux-2.6.7
) = 21
and it prints /usr/src/linux-2.6.7 to stdout no matter the parameter
given to pwd.
Anyone knows why that could happen?
( I haven't seen to the pwd code yet though)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: stracing pwd
2004-06-19 15:29 stracing pwd David Eduardo Gómez Noguera
@ 2004-06-19 16:13 ` Christoph Bussenius
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Bussenius @ 2004-06-19 16:13 UTC (permalink / raw)
To: linux-c-programming; +Cc: Linux C Programming
On Sat, Jun 19, 2004 at 10:29:40AM -0500, David Eduardo Gómez Noguera wrote:
> /usr/src/linux-2.6.7
> /usr/src/linux -> /usr/src/linux-2.6.7
>
> under /usr/src/linux,
> pwd prints /usr/src/linux
> pwd -L too
> pwd -P prints /usr/src/linux-2.6.7
> but an strace always shows the same
> write(1, "/usr/src/linux-2.6.7\n", 21/usr/src/linux-2.6.7
> ) = 21
> and it prints /usr/src/linux-2.6.7 to stdout no matter the parameter
> given to pwd.
>
> Anyone knows why that could happen?
> ( I haven't seen to the pwd code yet though)
The difference is that the first time you call pwd, you actually call
the shell builtin named pwd. The second time you call pwd, you call
/bin/pwd. The shell thinks you are where you have cd'd to, but in fact,
you are in /usr/src/linux-2.6.7. Just try typing /bin/pwd in the shell.
Cheers,
Christoph
--
``There's no dark side of the moon, really
Matter of fact, it's all dark''
--Pink Floyd
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-06-19 16:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-19 15:29 stracing pwd David Eduardo Gómez Noguera
2004-06-19 16:13 ` Christoph Bussenius
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).