[Toybox] xxd -ps

enh enh at google.com
Thu Nov 29 16:29:23 PST 2018


On Sat, Nov 17, 2018 at 1:01 PM Rob Landley <rob at landley.net> wrote:
>
> On 11/15/18 6:38 PM, enh wrote:
> > so xxd has some weird cancers, and i've been ignoring them, and have
> > uploaded https://android-review.googlesource.com/c/platform/build/+/828285
> > to AOSP to stop using -ps, but i'm mildly curious...
> >
> > given that xxd has a -p and a -s (which takes a numeric argument),
> > what would we have to do to also accept -ps as a synonym for -p
> > (rather than as -p plus -s but missing a numeric argument)? i'm
> > assuming that would be awful and not worth it?
>
> I... er...  what?
>
> > from the xxd man page:
> >
> >        -p | -ps | -postscript | -plain
> >               output  in  postscript  continuous  hexdump style. Also known as
> >               plain hexdump style.
>
> That's... ouch.
>
> Somebody pointed out a corner case where the "ps" command had some similar
> insanity, but given that I haven't yet implemented the bsd-style options
> (despite "ps ax" being hardwired into my muscle memory at this point) I flung
> the note at the end of a todo list I can't currently find. (I think I had a
> window open with it on the netbook that died.)
>
> > is there a way to say "this bizarre command's longopts actually use a
> > single -"? are there any commands other than xxd that would even use
> > this?
>
> Yeah, gcc and kill both do that. I'm not implementing a compiler in toybox (if I
> get a chance at qcc it's a separate project) and did kill another way.
>
> Hmmm... I could add a lib/args.c optstring prefix character to tell it "check
> for longopts before parsing each single dash option group"? That wouldn't be too
> hard. That would still treat "-lps" as "-l -p -s" rather than "-l -ps" but
> assuming that's what we want here...
>
> Hmmm, should I keep it unique and use "`" or some such, or use "-" for this and
> have that mean two different things when coming after an option vs when coming
> before all options? (The code probably doesn't care but the users might.)
>
> Rob
>
> P.S. Projects accumulate complexity as they encounter more of the real world.
> It's kind of annoying.

to be clear: i think this is a terrible idea and we should just say
"no" until/unless we have a genuinely compelling example. (which i
don't think this is.)

but if you already the toybox equivalent of getopt_long_only
(http://man7.org/linux/man-pages/man3/getopt.3.html) lying around,
well, no, i'd probably still have said "YAGNI" and not actually used
it for xxd anyway.



More information about the Toybox mailing list