On 6/21/21 5:19 PM, Denys Vlasenko wrote:
> On Mon, Jun 21, 2021 at 10:17 PM Rob Landley <[email protected]> wrote:
>> Huh, apparently https://github.com/landley/toybox/commit/cd358823399a didn't
>> revert enough of commit e191597e6bbf0. The changed help text is still there, 
>> but
>> not implemented.
>>
>> Yes, you found a toybox bug nobody's poked me about: once upon a time I
>> accidentally did a commit without --patch and thus the help text of the 
>> command
>> includes stuff that was under consideration at one point, but never got 
>> implemented.
> 
> Looking at toybox's help texts, I noticed a few more:
> 
> free [-bkmgt]
>         Display the total, free and used amount of physical memory and
> swap space.
>         -bkmg*t Output units (default is bytes)
> ^^^^^^^ in procps-ng 3.3.15, "free -t" is not "terabytes", it's --total

Probably an accident. (The original submission just had -bkmg and no other
options, I probably saw -t in the old one line --help output and added what it
"obviously meant" when doing a cleanup pass, otherwise I would have added -ped 
too).

Nobody's mentioned it before now because the command's not in SUSv4, not in LSB
4.1, and its output is harder for scripts to parse than /proc/meminfo:

$ echo $(($(sed -nE 's/^(Mem|Swap)Total:[ \t]*([0-9]*).*/+\2/p' /proc/meminfo)))
33006412

I tend to wait for people to show up with a complaint attached to a real-world
use case and do lazy-binding decision making then. Now that somebody's showed up
who cares, would:

  A) always showing total
  B) implementing --total longopt without the -t short option
  C) changing -t to show total instead of terabytes
  D) removing -t

be less unpleasant?

Apparently NOT having options is the morally justifiable way to break people's
scripts, which would argue for D.

To me, option C is the worst because that's INTERNALLY INCONSISTENT, which is a
thing toybox tries to avoid being:

  $ toybox --help
  ...
  Numerical arguments accept a single letter suffix for
  kilo, mega, giga, tera, peta, and exabytes, plus an additional
  "d" to indicate decimal 1000's instead of 1024.

Hence the "would have added -ped" above to meet user expectations about "how
toybox commands work".

But this is not a widely used command (because /proc/meminfo exists), and
systems too small to have /proc mounted generally already know exactly how much
memory they have and/or do their own sysinfo() call in a monolithic app, so
you're the first person to care enough to mention it.

> hexedit FILE
>         Hexadecimal file editor/viewer. All changes are written to
> disk immediately.
>         -r      Read only (display but don't edit)
> ^^^^^^^ hexedit 1.5 has no such opt

So you're saying that an interactive GUI utility (which cannot be used in a
non-interactive mode) may not be compatible with existing shell scripts. I'm not
convinced this issue is why?

I wrote toys/other/hexedit.c from scratch. I was unfamiliar with any existing
interactive hex editor for linux because it's never been installed on any Linux
system I'm familiar with, and still isn't:

  $ hexedit
  bash: hexedit: command not found

The first hex editor I wrote from scratch was my first "big" program, back on
the commodore 64 circa 1983 or so. This one works a bit like that one,
especially in using the petascii display inversion tricks for low and high
characters not otherwise standardly displayable.

This hexedit is not being "compatible" with any existing Linux program. It's
just an interactive hex editor.

> shred [-fuz] [-n COUNT] [-s SIZE] FILE...
>         Securely delete a file by overwriting its contents with random data.
>         -f              Force (chmod if necessary)
>         -n COUNT        Random overwrite iterations (default 1)
>         -o OFFSET       Start at OFFSET
> ^^^^^ -o not in coreutils-8.32

Kind of an obvious hole in the API though, isn't it? Ability to specify a length
but not a starting location?

Not that shred is going to accomplish much by itself on a log structured flash
filesystem, you need to follow it up with discard which only some
devices/drivers actually implement (and whether it's just an accounting measure
and they defer erasing the erase blocks is a whole 'nother can of worms, varies
by manufacturer; this was designed for spinning rust and doesn't always map well
to modern storage).

I only added shred because somebody asked me to. Specifically it looks like
Tizen wanted it in 2014? Briefly, it dropped off their list but I'd already
added it. Initial motivating user went away again, but I didn't remove it again
because eh, there's one in coreutils. You can tell that command hasn't gotten a
lot of love because the usage: line doesn't include all the options below it.
(*shrug* Fixed that while I was there...)

---

Thanks for the code review, free and shred don't get a lot of attention.
(Hexedit Elliott and I argued about at some length a couple months back ala
http://lists.landley.net/pipermail/toybox-landley.net/2021-April/012398.html and
I wound up making an interface toggle key (x) to switch between his and my
display type. Nobody mentioned another version in that discussion that I 
recall?)

Rob
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to