help-bash
[Top][All Lists]
Advanced

[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: Koichi Murase
Subject: Re: How does quote removal work with alternative forms of parameter expansion?
Date: Mon, 27 May 2024 09:20:47 +0900

2024年5月27日(月) 8:57 Koichi Murase <myoga.murase@gmail.com>:
> e.g. you can check the behavior of
>
>   x="${1:-"foo\ bar"foo\ bar"foo\ bar"}"
>
> which becomes
>
>   foo barfoo\ barfoo bar
>
> This is because it is somewhat equivalent to
>
>   x=""foo\ bar"foo\ bar"foo\ bar""
>
> This behavior seems strange, but this is the traditional behavior of
> Bash. As far as I can test, Bash 2.0 of 1996 (28 years ago) already
> has this behavior. ksh93 seems to behave in the same way.

I confirmed that Bourne sh.also behaves in the same way as Bash. (I
checked Heirloom Bourne sh and Solaris 11 /usr/sunos/bin/sh, and both
behave in the same way).

> [...]
>
> Another case you might be interested in is
>
> x="${1:-"foo \bar"foo\ bar"foo\ bar"}"

Sorry this repeated part was just a stub of the above part. I forgot
to remove this after moving the text.

--
Koichi



reply via email to

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