On 7/30/25 5:15 PM, Robert Elz wrote:
     Date:        Wed, 30 Jul 2025 09:31:52 -0600
     From:        Stan Marsh <gaze...@xmission.com>
     Message-ID:  <e1uh8mw-0000000eygt-0...@shell.xmission.com>

   | I wonder why "" was previously special-cased.

Once upon a time, chdir("") would have acted the same as chdir(".")
because in the kernel, the pathname lookup would see that this is
a relative path (doesn't start with '/') so the path lookup starts
at "." then it would extract the next pathname segment - but as there
isn't one, the pathname given has ended.   We're currently at "."
when the search ends, all good, use that.

That is essentially what happens when you use the POSIX algorithm as
provided in

https://pubs.opengroup.org/onlinepubs/9799919799/utilities/cd.html

except you run through $CDPATH first. You append the directory name
argument to $PWD, remove a trailing slash, and you're left with $PWD.

So if you want to make `cd ""' an error, you have to call it out
explicitly, or special-case it throughout the description.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to