Discussion:
[Toybox] xxd -ps
enh
2018-11-16 00:38:16 UTC
Permalink
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?

from the xxd man page:

-p | -ps | -postscript | -plain
output in postscript continuous hexdump style. Also known as
plain hexdump style.

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?
Rob Landley
2018-11-17 21:01:07 UTC
Permalink
Post by enh
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?
Post by enh
-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.)
Post by enh
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.
Rob Landley
2018-11-30 02:08:04 UTC
Permalink
Post by Rob Landley
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.)
I'm all for that approach.




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.
I've got "tar xvCf dirname filename file..." logic, which I need to enable for
"ps" as well. (It's on the todo list.)

But I tend to use short options when they're available. It's unix: make it more
verbose doesn't help.

Rob

Continue reading on narkive:
Loading...