Re: pwd(1) pwd -L and multple adjacent slashes in $PWD,
Geoff Clare wrote: > Joerg Schilling wrote, on 14 Apr 2020: > > > > Geoff Clare wrote: > > > > > casper@oracle.com wrote, on 14 Apr 2020: > > > > > > (cd /home/casper; PWD=/home///casper pwd -L) > > > > /home///casper > > > > > > > > > > > > Is this a correct implmentation? > > > > > > Yes. > > > > I know of no shell that behaves this way. > > Casper asked whether the standard allows the behaviour, not whether > any existing shell behaves that way. So OK Casper, why do you ask? Do you have a specific target in mind? BTW: Since a while, I do not get my own postings back from this list. Does this apply to everyone? Jörg -- EMail:jo...@schily.net(home) Jörg Schilling D-13353 Berlin joerg.schill...@fokus.fraunhofer.de (work) Blog: http://schily.blogspot.com/ URL: http://cdrecord.org/private/ http://sf.net/projects/schilytools/files/'
Re: pwd(1) pwd -L and multple adjacent slashes in $PWD,
Joerg Schilling wrote, on 14 Apr 2020: > > Geoff Clare wrote: > > > casper@oracle.com wrote, on 14 Apr 2020: > > > > (cd /home/casper; PWD=/home///casper pwd -L) > > > /home///casper > > > > > > > > > Is this a correct implmentation? > > > > Yes. > > I know of no shell that behaves this way. Casper asked whether the standard allows the behaviour, not whether any existing shell behaves that way. -- Geoff Clare The Open Group, Apex Plaza, Forbury Road, Reading, RG1 1AX, England
Re: pwd(1) pwd -L and multple adjacent slashes in $PWD,
Geoff Clare wrote: > casper@oracle.com wrote, on 14 Apr 2020: > > (cd /home/casper; PWD=/home///casper pwd -L) > > /home///casper > > > > > > Is this a correct implmentation? > > Yes. I know of no shell that behaves this way. Jörg -- EMail:jo...@schily.net(home) Jörg Schilling D-13353 Berlin joerg.schill...@fokus.fraunhofer.de (work) Blog: http://schily.blogspot.com/ URL: http://cdrecord.org/private/ http://sf.net/projects/schilytools/files/'
Re: pwd(1) pwd -L and multple adjacent slashes in $PWD,
Date:Tue, 14 Apr 2020 16:05:50 +0200 From:casper@oracle.com Message-ID: <202004141405.03ee5oki022...@room101.nl.oracle.com> | 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
Re: pwd(1) pwd -L and multple adjacent slashes in $PWD,
Chet Ramey wrote, on 14 Apr 2020: > > On 4/14/20 10:05 AM, casper@oracle.com wrote: > > > >> On 4/14/20 9:44 AM, casper@oracle.com 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. > > > > > > 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) > > Yes. It's unspecified. It would also be allowed to write a diagnostic message such as "PWD tampering by application detected" and exit with non-zero status. -- Geoff Clare The Open Group, Apex Plaza, Forbury Road, Reading, RG1 1AX, England
Re: pwd(1) pwd -L and multple adjacent slashes in $PWD,
On 4/14/20 10:05 AM, casper@oracle.com wrote: > >> On 4/14/20 9:44 AM, casper@oracle.com 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. > > > 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) Yes. It's unspecified. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Re: pwd(1) pwd -L and multple adjacent slashes in $PWD,
>On 4/14/20 9:44 AM, casper@oracle.com 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. 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) Casper
Re: pwd(1) pwd -L and multple adjacent slashes in $PWD,
>casper@oracle.com wrote, on 14 Apr 2020: >> >> 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? > >Yes. Thanks. >> Is it *required* for the implementation to behave this way? > >No. See the description of PWD under "ENVIRONMENT VARIABLES" on >the pwd page: > >If an application sets or unsets the value of PWD, the behavior of >pwd is unspecified. But if the application sets it to these values and these are proper absolute pathnames of the current working directory, then that is the value we need to print? Casper
Re: pwd(1) pwd -L and multple adjacent slashes in $PWD,
On 4/14/20 9:44 AM, casper@oracle.com 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, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Re: pwd(1) pwd -L and multple adjacent slashes in $PWD,
casper@oracle.com wrote, on 14 Apr 2020: > > 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? Yes. > Is it *required* for the implementation to behave this way? No. See the description of PWD under "ENVIRONMENT VARIABLES" on the pwd page: If an application sets or unsets the value of PWD, the behavior of pwd is unspecified. -- Geoff Clare The Open Group, Apex Plaza, Forbury Road, Reading, RG1 1AX, England
pwd(1) pwd -L and multple adjacent slashes in $PWD,
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? Is it *required* for the implementation to behave this way? Casper