View Issue Details

IDProjectCategoryView StatusLast Update
00001241003.1(2008)/Issue 7Shell and Utilitiespublic2013-04-16 13:06
Reportereblake Assigned Toajosey  
PrioritynormalSeverityObjectionTypeOmission
Status ClosedResolutionAccepted As Marked 
NameEric Blake
Organization
User Referenceebb.tilde
SectionTilde Expansion
Page Number2305
Line Number72682
Interp Status---
Final Accepted Text0000124:0000199
Summary0000124: tilde expansion and double slash file names
DescriptionThe standard is silent on how tilde expansion must behave on implementations where // is different than /. See also https://www.opengroup.org/sophocles/show_mail.tpl?CALLER=show_archive.tpl&source=L&listname=austin-group-l&id=8491.

This proposal tries to codify the approach used when porting shells to cygwin, where // really is distinct from /. The intent is that:

HOME=/; a=~:~/dir:~//dir; HOME=//; b=~:~/dir:~//dir; echo $a $b

outputs "/:/dir://dir //://dir:///dir", such that using one slash between a tilde prefix and subsequent text never corrupts / into // or // into /, but using two slashes after a tilde prefix intentionally picks up the opposite sense. If one wants to avoid the // issue altogether but still use the root directory, then HOME can be set to ///.

However, this could have a negative impact to existing implementations, where // is identical to / during pathname resolution. On those platforms, not deleting a trailing slash during tilde-expansion will have no impact to pathname resolution, but leads to observably different textual expansion. So it may be worth adding additional wording that permits platforms to skip stripping the trailing slash if // is identical to /.
Desired ActionAfter the existing text at line 72682:

If the login name is null (that is, the tilde-prefix contains only the tilde), the tilde-prefix is replaced by the value of the variable HOME. If HOME is unset, the results are unspecified. Otherwise, the tilde-prefix shall be replaced by a pathname of the initial working directory associated with the login name obtained using the getpwnam( ) function as defined in the System Interfaces volume of POSIX.1-2008. If the system does not recognize the login name, the results are undefined.

Add a new paragraph:

If the replacement provided by the variable HOME or by getpwnam( ) ends in a <slash>, and the tilde-prefix was terminated by a <slash>, then the trailing slash in the replacement shall be omitted when concatenating the expansion with the rest of the word. If the tilde-prefix was terminated by <colon> or the end of the word, then the trailing slash of the replacement is left intact.
Tagstc1-2008

Activities

ajosey

2009-08-20 15:59

manager   bugnote:0000199

On 124 we noted that introducing a change here would likely cause breakage
for someone.

Making the change proposed could break existing scripts written to conform
to the standard. We would like a better understanding of the
extent of the problem on a cygwin system.

We are leaning towards adding a note to RATIONALE,

Add to XRAT p3655 124299

System administrators on systems where // has an implementation
defined meaning which is different to /, should
not create users with a home directory of / or //, since this may lead
to unexpected filename resolution on those systems.

Issue History

Date Modified Username Field Change
2009-07-15 04:10 eblake New Issue
2009-07-15 04:10 eblake Status New => Under Review
2009-07-15 04:10 eblake Assigned To => ajosey
2009-07-15 04:10 eblake Name => Eric Blake
2009-07-15 04:10 eblake User Reference => ebb.tilde
2009-07-15 04:10 eblake Section => Tilde Expansion
2009-07-15 04:10 eblake Page Number => 2305
2009-07-15 04:10 eblake Line Number => 72682
2009-08-20 15:59 ajosey Note Added: 0000199
2009-10-08 15:49 msbrown Interp Status => ---
2009-10-08 15:49 msbrown Final Accepted Text => 0000124:0000199
2009-10-08 15:49 msbrown Status Under Review => Resolved
2009-10-08 15:49 msbrown Resolution Open => Accepted As Marked
2010-08-27 13:15 ajosey Tag Attached: tc1-2008
2013-04-16 13:06 ajosey Status Resolved => Closed