bug-bash
[Top][All Lists]
Advanced

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

Re: ${name} vs ${name-} with ${...//...}


From: Zachary Santer
Subject: Re: ${name} vs ${name-} with ${...//...}
Date: Mon, 16 Jun 2025 16:26:05 -0400

On Mon, Jun 16, 2025 at 1:57 PM Zachary Santer <zsanter@gmail.com> wrote:
>
> You can't combine multiple forms of parameter expansion into one thing
> like this. If name is unset, "${name-//\"/}" will do what the
> ${parameter-word} expansion does and expand to //"/.
>
> If you want the combined effect of multiple forms of parameter
> expansion, you're going to have to use multiple parameter expansions.
> In your case, that would probably look like this:
> name="${name-}"
> name="${name//\"/}"

If bash were to support multiple forms of parameter expansion in one
expansion, that could potentially be written in a nested fashion, like
"${{paramter-word}/pattern/string}"
but, uh, definitely not a necessity. Probably not great for readability.



reply via email to

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