Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #16599
| From | Greg Wooledge <wooledg@eeg.ccf.org> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Re: Assignment-like word shouldn't be subjected to tilde expansion in POSIX mode |
| Date | 2020-07-21 08:30 -0400 |
| Message-ID | <mailman.281.1595334613.24492.bug-bash@gnu.org> (permalink) |
| References | (1 earlier) <8ddc4816-f85e-97b3-5c51-9b55acdcaca5@case.edu> <9881b6b4-237f-ea61-d9fc-9c3f9f9ae4c3@yahoo.com> <20200721114844.GQ22833@eeg.ccf.org> <5098cfe1-6de1-b22d-d8e9-a26ba0b3b991@yahoo.com> <20200721123005.GS22833@eeg.ccf.org> |
On Tue, Jul 21, 2020 at 03:14:59PM +0300, M. Nejat AYDIN wrote: > On 7/21/20 2:48 PM, Greg Wooledge wrote: > > On Tue, Jul 21, 2020 at 10:55:06AM +0300, M. Nejat AYDIN wrote: > > > Also, shouldn't the tilde be expanded following > > > $ echo ~: > > > ? The colon terminates tilde-prefix in an assignment, but there is no > > > assignment involved here. > > > > Works for me. > > > > unicorn:~$ echo ~: > > /home/greg: > > > > Also in POSIX mode. > > > > Oops, I've misstated. > I think the tilde in > $ echo ~: > shouldn't have been expanded and should have been printed verbatim: > ~: Tilde Expansion, according to POSIX: 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 <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>. 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. [...] If the system does not recognize the login name, the results are undefined. For the record, ksh does the same as bash. Dash leaves the tilde unexpanded. Obviously, I am assuming that one does not have a user named : (as that would be basically impossible on any unix that uses an /etc/passwd file in the traditional format). I have no objection to bash's decision here. I actually find it less surprising than dash's decision, although both are rational ones.
Back to gnu.bash.bug | Previous | Next | Find similar
Re: Assignment-like word shouldn't be subjected to tilde expansion in POSIX mode Greg Wooledge <wooledg@eeg.ccf.org> - 2020-07-21 08:30 -0400
csiph-web