|Anonymous | Login||2018-12-15 23:59 UTC|
|Main | My View | View Issues | Change Log | Docs|
|Viewing Issue Simple Details|
|ID||Category||Severity||Type||Date Submitted||Last Update|
|0001172||[1003.1(2016)/Issue7+TC2] Shell and Utilities||Objection||Enhancement Request||2017-11-24 17:32||2017-11-24 17:32|
|Final Accepted Text|
|Summary||0001172: shell tilde expansion. Clarify ~"user" ~user@domain ~$user ~$(logname) ~-1...|
The spec currently says:
> If none of the characters in the tilde-prefix are quoted, the
> characters in the tilde-prefix following the <tilde> are
> treated as a possible login name from the user database.
However, it's not clear what happens if any of those characters
Also, a portable username is defined as [a-zA-Z._][a-zA-Z._-]*
(in both the $LOGNAME description and the "User name" base
definition, it may be worth having one refer to the other to
avoid duplication) but it's not clear whether the expansion of
~user@domain for instance, that is where the tilde prefix is not
a "portable user name" is defined or not (if getpwnam() knows
it for instance).
There is a lot of variation in that regard between
implementations, and the end result is that one can't expect
anything if the tilde prefix is anything but
^~[a-zA-Z._][a-zA-Z._-]*$ (as a BRE in the POSIX locale)
so it would be worth stating more clearly, and also add some
examples of typical cases where users could expect tilde
expansion to work but where it doesn't in practice in several
implementations like ~$user, ~"user", ~$(logname), ~"/bin"
Adding a way to retrieve the home directory of an arbitrary user
would also be useful. FreeBSD has "id -P" (also getent passwd on
several systems) though it doesn't work for users whose username
or gecos or home contains colons or newlines.
Change the content of the Tilde Expansion section to:
A "tilde-prefix" consists of an unquoted <tilde> character at
the beginning of a word, followed by all of the characters
preceding the first unquoted <slash> in the word, or all the
characters in the word if there is no unquoted <slash>. In an
assignment (see XBD Variable Assignment), multiple
tilde-prefixes can be used: at the beginning of the word (that
is, following the <equals-sign> of the assignment), following
any unquoted <colon>, or both. A tilde-prefix in an assignment
is terminated by the first unquoted <colon> or <slash> or the
end of the assignment word.
If the "tilde-prefix" consists of only the tilde character, it
is replaced by the value of the variable HOME. If HOME is unset,
the results are unspecified.
If the tilde-prefix, without the tilde character does not match
the syntax of a portable user name (ref to $LOGNAME), the
results are undefined.
In particular, the results for ~"string", ~$var, ~foo@bar,
~"/bin", ~-1 are undefined as ", $, / and @ are not
characters of the portable filename character set and -1 is
not a portable username.
Otherwise, that tilde-prefix removed of the tilde character
shall be treated as a login name and the "tilde-prefix" shall be
replaced by a pathname of the initial working directory
associated with that 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.
|Tags||No tags attached.|
|There are no notes attached to this issue.|
|2017-11-24 17:32||stephane||New Issue|
|2017-11-24 17:32||stephane||Name||=> Stephane Chazelas|
|2017-11-24 17:32||stephane||Section||=> Tilde Expansion|
|2017-11-24 17:32||stephane||Page Number||=> 2354|
|2017-11-24 17:32||stephane||Line Number||=> 75026-75034|
|Mantis 1.1.6[^] Copyright © 2000 - 2008 Mantis Group|