[Toybox] Inconsistent gnu crap.

enh enh at google.com
Mon Apr 13 17:38:15 PDT 2020


i was shocked when i looked at this back when i wanted to get all the
toys onto the same implementation --- testing the various GNU tools
that support escapes, they all seemed to support slightly different
subsets, with slightly different interpretations of corner cases
(including some that preferred to report an error rather than "take a
side").

if we were starting again from scratch, i'd definitely favor
consistency but as it is, i have the same fear as you that there's
stuff out there relying on all these ugly corner cases.

did busybox try to unify the various users of escaping?

(the best alternative i could think of was One True unescape that took
a bunch of flags for all the variants. but even getting a complete
list of all the variants seemed like enough of a challenge that i just
moved on to other stuff instead.)

On Mon, Apr 13, 2020 at 10:13 AM Rob Landley <rob at landley.net> wrote:
>
> On 4/13/20 12:12 PM, Rob Landley wrote:
> > Hmmm... would echo -n '\123' being parsed into hex 53 be a BAD thing? (Right now
> > it's passed through as literals but understanding EXTRA escapes shouldn't cause
> > too much trouble? The question is whether I preparse to add extra behavior,
> > which I'm already doing for \c ending the string early, or whether I need to add
> > an extra argument to unescape() to tell it to behave differently in different
> > situations. I can easily make it so the rule is "the first leading zero in an
> > echo octal escape gets eaten"...)
>
> Sigh:
>
> $ sh -c 'echo "\123"' | hd
> 00000000  53 0a                                             |S.|
> 00000002
>
> The echo built into the Defective Annoying SHell is already doing what I was
> suggesting. I'm not sure if that's an argument for or against. (I suspect
> "against'. Hmmm...)
>
> Then again, the defective annoying shell's built-in echo doesn't understand -e:
>
> $ sh -c 'echo -e "\123"' | hd
> 00000000  2d 65 20 53 0a
>
> Yeah, dash doing that is definitely an argument _against_ doing it. Hmmm. (I
> _might_ do it anyway, but dash doing it definitely makes me reconsider.)
>
> Rob
> _______________________________________________
> Toybox mailing list
> Toybox at lists.landley.net
> http://lists.landley.net/listinfo.cgi/toybox-landley.net



More information about the Toybox mailing list