[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: parameter expansion with `:` does not work
From: |
Lawrence Velázquez |
Subject: |
Re: parameter expansion with `:` does not work |
Date: |
Wed, 7 Jul 2021 23:23:48 -0400 |
> On Jul 7, 2021, at 10:38 PM, lisa-asket@perso.be wrote:
>
> Correct. How do others customarily use `${fdir:=$PWD}` ?
The common idiom is
: "${fdir:=$PWD}"
The ':' utility is used because it does nothing, but its arguments
are expanded as usual.
> I'd rather understand what's going on, rather than simply never use it.
Think about what is happening here:
fdir=${fdir:=$PWD}
This is conceptually equivalent to
if [[ -z "$fdir" ]]; then
fdir="$PWD"
fi
fdir="$fdir"
I hope you can see why this is a pointless thing to do.
--
vq
- parameter expansion with `:` does not work, (continued)
- Re: parameter expansion with `:` does not work, Greg Wooledge, 2021/07/07
- parameter expansion with `:` does not work, lisa-asket, 2021/07/07
- Re: parameter expansion with `:` does not work, Chet Ramey, 2021/07/07
- parameter expansion with `:` does not work, lisa-asket, 2021/07/07
- Re: parameter expansion with `:` does not work, Dennis Williamson, 2021/07/07
- Re: parameter expansion with `:` does not work, Greg Wooledge, 2021/07/07
- Re: parameter expansion with `:` does not work, Kerin Millar, 2021/07/07
- parameter expansion with `:` does not work, lisa-asket, 2021/07/07
- Re: parameter expansion with `:` does not work,
Lawrence Velázquez <=
- parameter expansion with `:` does not work, lisa-asket, 2021/07/08
- Re: parameter expansion with `:` does not work, Greg Wooledge, 2021/07/07
- parameter expansion with `:` does not work, lisa-asket, 2021/07/08