Date: Tue, 14 Apr 2020 16:05:50 +0200
From: [email protected]
Message-ID: <[email protected]>
| So you are saying that it would be fine to squish out the additional
| slashed in the output? (Not doing anything would be fine, too)
If you're asking about what the pwd command is required to do, and not
specifically about the examples that you gave, then if the pwd command
concerned is not a built-in utility in the shell, it cannot (according
to the standard) "squish out the additional slashes".
That's because the shell is allowed to set PWD to /some/weird///dir
if it wants to, which it might do after the sequence
cd /some
cd weird///dir
as it isn't required to "squish" the slashes in that case. (It is
permitted to, but isn't required). If it does that, then pwd (-L) is
required to print what the shell set for it.
On the other hand, if the pwd of concern is built into the shell, then
it knows whether it (the shell) would set the path that way - if it
wants to squish in the pwd command, then it would also squish in the cd
command, and there would never be consecutive (non-leading, which is a
special case) slashes in $PWD and consequently, if pwd sees that, something
else must have set PWD, in which case we're in the undefined territory
that Geoff referred to.
All that said - do whatever you like. The -L option to cd and pwd is
an abomination that should be deleted (from everywhere). It is
unconscionable that "ls .." and "cd ..; ls" might list different
directories - which is the result (one of the horrid results) that
"cd -L' permits (pwd -L is meaningless without "cd -L" to set PWD for it).
kre