Settings

Theme

How Does Pwd Operate?

gclv.es

2 points by gclv 5 years ago · 2 comments

Reader

zxcmx 5 years ago

I think the spirit of the post was to investigate through source spelunking.

Since there is so much history I often find it hard to see why things work the way they do, just by looking at how they work.

If one is ready to "cheat" on the question and look at a ready made answer this one is quite good: https://unix.stackexchange.com/questions/413204/how-does-uni...

I would summarise the reasons behind common UNIX shell implementation(s) of this as "directory names are not stable over the lifetime of a process" and "$PWD cannot be trusted".

  • gclvOP 5 years ago

    Thanks for the link. The original implementation of getcwd resolving .. until it loops is a delightful piece of cleverness I wasn’t aware of.

    This type of simple, clever design is what’s prompted me to pick up “the unix programming environment”, though I’m sure most of what it talks about it outdated. It’s been a fun read so far!

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection