[Toybox] Inconsistent gnu crap.

Rob Landley rob at landley.net
Mon Apr 13 10:12:59 PDT 2020


I'm redoing the unescape() long to advance through strings (so it can handle
octal and hex escapes and such), but:

  $ echo -ne '\0132' | hd
  5a
  $ echo -n $'\0132'
  0b 32

Because bash takes three \nnn digits as the octal number for $'' but echo takes
\0nnn with an obligatory leading zero THEN three digits.

I hate gnu everything.

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"...)

Rob



More information about the Toybox mailing list