[Toybox] Would someone please explain what bash is doing here?
Rob Landley
rob at landley.net
Mon May 25 03:39:43 PDT 2020
On 5/24/20 4:32 PM, Chet Ramey wrote:
>> In new tab:
>> $ echo $LINENO\
>> > $LINENO
>> 22
>> $ echo $LINENO
>> 3
>>
>> It cares about the space.
>
> Of course it does!
It's not an "of course" for me. My code doesn't work like that.
> The space terminates the token!
Unquoted tokens self-terminate: ; or & or ( don't need a space before or after
them to be their own word. Therefore $LINENO can already _not_ be a function
definition before you get to the \ because it started with something _other_
than an unquoted "(".
> You can't return the
> first $LINENO until you process the backslash-newline and find a
> metacharacter that ends the word, which is the newline after the second
> $LINENO.
It's already categorized the word by that point and knows it's not a control
character. The trailing \ makes it return "need next line due to unfinished
quote" but the calling code doesn't behave differently because of it.
Rob
More information about the Toybox
mailing list