help-bash
[Top][All Lists]
Advanced

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

Re: How is ${x:-"} parsed?


From: Eli Schwartz
Subject: Re: How is ${x:-"} parsed?
Date: Sun, 9 May 2021 17:06:30 -0400

On 5/9/21 5:02 PM, Peng Yu wrote:
> On 5/9/21, Eli Schwartz <eschwartz@archlinux.org> wrote:
>> On 5/9/21 4:48 PM, Peng Yu wrote:
>>> I see the following command is expecting something. I don't quite
>>> understand how it is parsed.
>>>
>>> $ echo "${x:-"}"
>>
>> $ echo "${x:-"}"}"
>> }
> 
> Sorry that my question was not clear. I mean, given the bash already
> at the state where it prints ">", how to close the second quote.
> 
> If there is no way to close the quote at ">", why prints it? So it is
> related to the suboptimal parsing ability of the current
> implementation of bash?

You can close the second quote as soon as you close the ${

$ echo "${x:-"}"
> }"
}

$

When prompted with the >, I accepted that "}" followed by the newline
character was the replacement value of $x, and closed it off by }"

Then, echo has duly printed out } followed by a newline.

-- 
Eli Schwartz
Arch Linux Bug Wrangler and Trusted User

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

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