[Toybox] sed -i

enh enh at google.com
Tue Dec 11 17:23:13 PST 2018


On Tue, Dec 11, 2018 at 5:15 PM Rob Landley <rob at landley.net> wrote:
>
> On 12/11/18 5:34 PM, enh wrote:
> > Ah, I didn't actually check the code --- I saw that the docs mentioned --color
> > but they strongly imply that ; is *only* for long options. (Though what does
> > that mean for -i versus --in-place? Maybe I should just try it and see what
> > happens!)
>
> I very vaguely recall that -iblah would need to _not_ have a space? (Because it
> doesn't know whether the next argument attaches to the -i or not unless there's
> no space so it can't _not_ attach. Just like --longopt=blah can just not have
> the =blah, and -ix could not have the x.)
>
> It's possible that's not what uptream is doing? When I added -i to busybox, sed
> didn't have an optional suffix for -i yet. (I was using knoppix at the time, I
> think? Don't remember which version.)
>
> The fun part of the option parsing logic was getting "echo -nex" to print "-nex"
> rather than parsing 2 and then baring. The _previous_ fun part was getting "tar
> xvzCf dirname filename" to work properly. And yes, I cared about both. There's a
> _reason_ it's not trying to use the libc optargs plumbing...
>
> I take it you have a script using the extension?

yeah, there's a bunch of `-i.bak`. the good news is that seems to be
the only thing that breaks if i switch AOSP builds over to toybox sed.
and other than the option parsing, actually implementing this seems
easy :-)

> Rob



More information about the Toybox mailing list