On 4/14/20 9:44 AM, [email protected] wrote:
> pwd has the -L option:
>
> The following options shall be supported by the implementation:
>
> -L
> If the PWD environment variable contains an absolute pathname
> of the current directory and the pathname does not contain any
> components that are dot or dot-dot, pwd shall write this
> pathname to standard output, except that if the PWD environment
> variable is longer than {PATH_MAX} bytes including the
> terminating null, it is unspecified whether pwd writes this
> pathname to standard output or behaves as if the -P option had
> been specified. Otherwise, the -L option shall behave as the -P
> option.
>
>
> It mentions "dot-dot" and "dot".
>
> It does seems to allow:
>
> (cd /; PWD=////////// pwd -L)
> //////////
> and
> (cd /home/casper; PWD=/home///////casper pwd -L)
> /home///////casper
>
>
> Is this a correct implmentation?
Does the standard cover this at all? It only mentions PWD being set by `cd'
and initialized by `sh'. If you assign it directly, at least `cd' is
explicitly unspecified, and since `pwd' is only required to "remove
unnecessary slash characters" if -P is supplied, I'd say you've left the
realm of the standard and the implementation can do what it likes.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU [email protected] http://tiswww.cwru.edu/~chet/