bug-bash
[Top][All Lists]
Advanced

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

parameter expansion with `:` does not work


From: lisa-asket
Subject: parameter expansion with `:` does not work
Date: Thu, 8 Jul 2021 04:38:25 +0200 (CEST)

> From: Kerin Millar <kfm@plushkava.net>
> To: Dennis Williamson <dennistwilliamson@gmail.com>
> Subject: Re: parameter expansion with `:` does not work
> Date: 08/07/2021 03:51:15 Europe/Paris
> Cc: lisa-asket@perso.be;
>    Greg Wooledge <greg@wooledge.org>;
>    bug-bash <bug-bash@gnu.org>;
>    Chester Ramey <chet.ramey@case.edu>

> On Thu, 8 Jul 2021 02:54:06 +0200 (CEST)
> lisa-asket@perso.be wrote:

> > As I was in it, have also changed  
> > 
> > fdir=${fdir:-$PWD}

> This makes sense.



> It makes sense, although one is using substitution and then setting it to the 
> same parameter. 



> > to 
> > 
> > fdir=${fdir:=$PWD} 

> Here, you are using a form of parameter expansion that intrinsically performs 
> variable 

> assignment, only to redundantly assign the result of the expansion to the 
> same variable once 

> again. 



Correct.  How do others customarily use `${fdir:=$PWD}` ?



> In a roundabout fashion, it ends up proving Greg's point. I'd suggest 
> temporarily disavowing 

> yourself of the ${parameter:=word} form, for the time being.



I'd rather understand what's going on, rather than simply never use it.






reply via email to

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