[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Change in indirect expansion behavior from 4.4 to 5.0

From: Chet Ramey
Subject: Re: Change in indirect expansion behavior from 4.4 to 5.0
Date: Wed, 30 Sep 2020 09:19:34 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.12.0

On 9/30/20 12:28 AM, Jason Miller wrote:
> Gentoo linux, GNU bash, version 5.0.18(1)-release (x86_64-pc-linux-gnu)
> On the above vesion of bash, the following script will not run the echo 
> command
> and print an error.  On bash 4.4 it appears to  treat the ${!foo} the same as
> expanding an unset variable and thus outputs "bar":
>   unset foo
>   echo ${!foo} bar

This is the result of


I explained the reasoning in


The basic idea is that indirect expansion is just a string substitution,
so indirecting an unset variable is the logically same thing as ${},
which is an expansion error.

``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/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]