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


Groups > gnu.bash.bug > #14453

Re: Tilde expansion in assignment-like context

Path csiph.com!3.us.feeder.erje.net!feeder.erje.net!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From Clint Hepner <clint.hepner@gmail.com>
Newsgroups gnu.bash.bug
Subject Re: Tilde expansion in assignment-like context
Date Mon, 6 Aug 2018 16:04:32 -0400
Lines 59
Approved bug-bash@gnu.org
Message-ID <mailman.4768.1533585881.1292.bug-bash@gnu.org> (permalink)
References <349F67EA-6EA7-4C8E-8E3A-AC36A82EBFBD@gmail.com> <3f04a0db-0583-d5d9-1faf-75deb76c1219@case.edu>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0 (Mac OS X Mail 10.3 \(3273\))
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding quoted-printable
X-Trace usenet.stanford.edu 1533585882 6955 208.118.235.17 (6 Aug 2018 20:04:42 GMT)
X-Complaints-To action@cs.stanford.edu
Cc bug-bash@gnu.org
To chet.ramey@case.edu
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=apS2VUfFVvnw5uc9vQIu54wd7rg/P8I/ZAujEJkbp8c=; b=TFx8bwxUmorz3Yc2ZXoK9RDzaraV3IR6XFypEx6J/XOXxwt4bhejTB9iSdneMbnx2S q6591HGMKd4lrw/xUVIcaq5GPXbXjPGVex+N5ANq4vklmHpxv8fhGqo7S55iUjnykAW9 hJ8TTeQ1LK4ZjdToJwiupiknPvmO5ggiiKNhTh56yCrbAYNuiJedUts7YSuXG/SNqwsh Bf8jXjpO9kAfOTnh5RCUUDmPjmWivtP0KgGHNatacWmZC5U66p7x1UNiBvcJkJRIlizL TQvgNC/ziQfA5iN28VavGdLsAUU16MRI8n+2FyYsr4o1URWcxpV16AOjXPt/PSohdarP 9SBQ==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=apS2VUfFVvnw5uc9vQIu54wd7rg/P8I/ZAujEJkbp8c=; b=hp/cOB4B9zNz0Nk7KaMv+5jblrI93KgcOQYwpu1i8ESHzxK5RF79GZKA/M9cXC4/EX HLU7CZOAS+sBoB0Hqpi5+YCH45A06nqA8xWvgneCwUBrPAtwhCXOKzMarqrOi49QBr4X Apkw69qcIhdS4BLEQAUot6i+WR+Cko9Aa5wIFG2ugKQBrL4np5H1UcNtDCMUd43J+/Uj RajU3eMVg6m3ZNq5cO6OJLLzqwLQiO6GkwvQk/266VkNh18YL25dvLKaA+78PiV2I0HJ 90BnYx3n5YbsdTKRlb+nidX77UUaic2hBIrLYMgXeYGAtLcfSB1bUGEJLDHhPSgzgbL5 Y0HQ==
X-Gm-Message-State AOUpUlHB7frBkZ0EkHjNyumDsUFrjR54Hh8cDKZJqJtLHTWv1Dp/otir doqoDm77ZaiYQ8/TKOz5AjnCiUeC
X-Google-Smtp-Source AAOMgpeb683zpe6x0v5Im6+dIqYLs+WtkJiuz6UgnD87FZzbRpBF6Wb8MSemJPTS05qCFyk02KsJeA==
X-Received by 2002:a37:bfc2:: with SMTP id p185-v6mr14320030qkf.169.1533585874780; Mon, 06 Aug 2018 13:04:34 -0700 (PDT)
In-Reply-To <3f04a0db-0583-d5d9-1faf-75deb76c1219@case.edu>
X-Mailer Apple Mail (2.3273)
X-detected-operating-system by eggs.gnu.org: Genre and OS details not recognized.
X-Received-From 2607:f8b0:400d:c09::229
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.21
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 <http://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>
Xref csiph.com gnu.bash.bug:14453

Show key headers only | View raw


> On 2018 Aug 6 , at 3:45 p, Chet Ramey <chet.ramey@case.edu> wrote:
> 
> On 8/6/18 3:09 PM, Clint Hepner wrote:
> 
>> Bash Version: 4.4
>> Patch Level: 19
>> Release Status: release
>> 
>> Description:
>>        A non-initial unquoted tilde is expanded outside of an assignment. This
>>        was raised as a question on Stack Overflow, https://stackoverflow.com/q/51713759/1126841.
>> 
>> Repeat-By:
>> 
>>        $ set +k
>>        $ echo home_dir=~
>>        home_dir=/Users/chepner
> 
> Yes. Bash has done this since its earliest days. A word that looks like an
> assignment statement has tilde expansion performed after unquoted =~ and :~
> no matter where it appears on the command line. This makes things like
> 
> 	make DESTDIR=~stager/bash-install
> or
> 	export PATH=/usr/local/bin:~/bin:/usr/bin
> 
> easy and convenient.

Oh, right. For some reason, I had it in my head that this was only intended
for builtins like export, and that their status as builtins somehow made
the argument be treated as an assignment. I hadn't thought at all about non-builtin
commands like make.

> 
> The first version I can find that implemented the =~ and :~ tilde expansion
> prefixes is bash-1.10 (1991). Those early versions would have expanded
> something like `--home_dir=~'. The first version that restricted it to
> words that satisfied the assignment statement restrictions is bash-2.0
> (1996).
> 
> Bash doesn't do this when it's in posix mode. The first version that
> implemented that was bash-1.14.0.
> 
> -- 
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
> 		 ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: Tilde expansion in assignment-like context Clint Hepner <clint.hepner@gmail.com> - 2018-08-06 16:04 -0400

csiph-web