help-bash
[Top][All Lists]
Advanced

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

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


From: Peng Yu
Subject: Re: How is ${x:-"} parsed?
Date: Sun, 9 May 2021 16:02:11 -0500

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've successfully quoted the }, even if you didn't *mean* to, now you
> need to end the ${
>
>>
>> Is the second double quote expecting another double quote to pair it?
>> If so, how to pair it?
>>
>> Alternatively, wouldn't it better to just print the error at the
>> second double quote since it should follow the dash character?
>
> Many programming language parsers have sub-optimal diagnostics when
> tripping over a grammatical syntax error and being unable to backtrack
> to the most likely place where the user made a mistake.
>
> bash: unexpected EOF while looking for matching `}'
>
> "unexpected EOF" while trying to find some terminating character and
> searching the *entire* file for it, is a pretty common error message
> here and in other languages.
>
> The most important thing to note is that:
> - a mistake was made
> - the beginning of the error relates to some use of {
>
>
> --
> Eli Schwartz
> Arch Linux Bug Wrangler and Trusted User
>
>


-- 
Regards,
Peng



reply via email to

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