[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How does quote removal work with alternative forms of parameter expa
From: |
Philippe Cerfon |
Subject: |
Re: How does quote removal work with alternative forms of parameter expansion? |
Date: |
Mon, 27 May 2024 03:51:39 +0200 |
On Mon, May 27, 2024 at 2:20 AM Greg Wooledge <greg@wooledge.org> wrote:
> What I would do is put the default string in a variable (which you can
> quote however you need to), and then use that variable in the conditional
> expansion.
Makes sense. And is not error prone. But of course - with now
(hopefully) understanding how it works - I could also just backslash
escape the ` in my string (and any other " \ $ or } ).
> This is because, to me, the rules are so insanely twisted and obscure
> that I can't possibly know them all.
They're actually not that twisted as expected. What really kept me
from understanding it myself was mostly two things:
- That "${var-"$foo"}" (i.e. the inside " " ) worked somehow
- That I didn't know about extquote
With that, and with the paragraphs Lawrence cited from the draft, it
does even make sense.
> One of the possible landmines here is that you've got the word "local"
> involved. So this is no longer a basic assignment command. Now it's
> a command whose argument simply has an = sign in the middle of it. Some
> shells may treat this like an assignment, with all the magic rules that
> assignments enjoy, and some may not.
Good point. One would hope that shells use just their normal handling
code, but that's of course not guaranteed.
What a pity that local couldn't be standardized - or that shell
developers at least agreed on some new keyword like loccal (or
something less dumb) where behavior is standardized and which works in
addition to the existing local.
Thanks as well,
Philippe
- How does quote removal work with alternative forms of parameter expansion?, Philippe Cerfon, 2024/05/26
- Re: How does quote removal work with alternative forms of parameter expansion?, Lawrence Velázquez, 2024/05/26
- Re: How does quote removal work with alternative forms of parameter expansion?, Philippe Cerfon, 2024/05/26
- Re: How does quote removal work with alternative forms of parameter expansion?, Lawrence Velázquez, 2024/05/26
- Re: How does quote removal work with alternative forms of parameter expansion?, Chet Ramey, 2024/05/29
Re: How does quote removal work with alternative forms of parameter expansion?, Koichi Murase, 2024/05/26