Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #16599

Re: Assignment-like word shouldn't be subjected to tilde expansion in POSIX mode

Path csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
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 Tue, 21 Jul 2020 08:30:05 -0400
Lines 46
Approved bug-bash@gnu.org
Message-ID <mailman.281.1595334613.24492.bug-bash@gnu.org> (permalink)
References <CAH7i3LqG=mnoiSbetxVdg3wqso5orGgMqQk70-UfJ=wcdf6uLQ@mail.gmail.com> <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>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Trace usenet.stanford.edu 1595334613 25480 209.51.188.17 (21 Jul 2020 12:30:13 GMT)
X-Complaints-To action@cs.stanford.edu
To bug-bash@gnu.org
Envelope-to bug-bash@gnu.org
Mail-Followup-To bug-bash@gnu.org
Content-Disposition inline
In-Reply-To <5098cfe1-6de1-b22d-d8e9-a26ba0b3b991@yahoo.com>
User-Agent Mutt/1.10.1 (2018-07-13)
Received-SPF none client-ip=139.137.100.1; envelope-from=wooledg@eeg.ccf.org; helo=mail.eeg.ccf.org
X-detected-operating-system by eggs.gnu.org: First seen = 2020/07/21 07:48:45
X-ACL-Warn Detected OS = Linux 2.2.x-3.x [generic] [fuzzy]
X-Spam_score_int -8
X-Spam_score -0.9
X-Spam_bar /
X-Spam_report (-0.9 / 5.0 requ) BAYES_00=-1.9, KHOP_HELO_FCRDNS=1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no
X-Spam_action no action
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <20200721123005.GS22833@eeg.ccf.org>
X-Mailman-Original-References <CAH7i3LqG=mnoiSbetxVdg3wqso5orGgMqQk70-UfJ=wcdf6uLQ@mail.gmail.com> <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>
Xref csiph.com gnu.bash.bug:16599

Show key headers only | View raw


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


Thread

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