I am not posting a reply this long to github, it's going to the list. :) On 8/15/23 15:57, David Legault wrote: > I guess you are right. On QNX we default to 512 because that's what the system > does so I guess I'll have to wedge in some code to set the value to blocksize > value to 1024 if you specify -k because it won't be a silent/noop option > anymore > for our system. I'll wait for the next release to have the blocksize change > and > adapt. Thanks.
The explanation from the 0.8.9 release would have been "If you change the default then -k is not a NOP, yes. Toybox accepts NOP arguments so as not to break scripts that use them, but doesn't document them because doing so doesn't tell you anything about what the command can do." (And the slightly more honest one might have been "death before ever calling anything a kibibyte".) However, now that we've added --block-size, specifying -k would logically set it _back_ to 1024, which would be easy to do if --block-size had a short argument because there's an "argument switches off other argument" syntax ala [-kX] that would both switch off the flag and blank any argument given the previous one. So: ls -k --block-size=123 Would ignore the -k, and: ls --block-size=123 -k Would ignore the --block-size. BUT, the trailing [] blocks work on short arguments. I never implemented a way to put a long argument that hasn't got a corresponding short argument into a square bracket argument list. BUT what I can do is associate a fake short argument with it, and if I give it nonsense using the octal escape syntax to set it to DEL (ascii 127, and yes if you -DEL on the command line somehow it would be a synonym for --block-size and somehow I can find it within myself to live with this issue)). And... fix the square bracket syntax to understand the octal escape syntax... and then fix the unassign logic to set it back to the DEFAULT value instead of clearning it to zero because "(block-size)#<1=1024" means it defaults to 1024 not to 0 and in this case setting it to 0 causes a division by zero error in the display logic which is why the <1 won't let you set it less than one... ./ls -s --block-size=1 -k And it's working. Except now I need to add help text _explaining_ it, which brings up the fact I -=TOTALLY CHEATED=- in the ls help text because the left column has 30 characters of space and the right column has 40 so "-k reset --block-size back to 1024" fits nicely on the right side but is one two long on the left side and the entries are currently in alphabetical order but inserting this on the left side of the "output formats" section A) won't fit B) would bump various other entries that then wouldn't fit. Sigh. I could move 13 entries one space to the right. OR, this is why I sometimes add options in pairs. Is there any low hanging fruit nonsense in the other ls between "h" and "k"? Hmmm, there's -I which looks interesting (is that new?) but that would go in "what to show" not in "output formats". Hmmm... rephrasing it as "reset --block-size to default" would fit. Except "-ll long with nanoseconds (--full-time)" still very much does NOT on the left side, but -ll is already a cheat so if I tweak the alphebetizing so -m is on its left and the -ll is under the -l (really it's "repeat -l for this different effect" but I couldn't come up with a concise way to SAY that which fit in the available space), and then the rest shuffle around to fit... Except there's now two lines with one entry in them, so I really want to find an "output format" I can call a "what to show" or vice versa so it packs into one less line. I'm aware I can't always fit help text into 80x25 but I still look at $ for i in $(toybox); do echo $i $(toybox --help "$i" | wc -l); done|sort -k2,2n ... ps 28 chattr 29 stat 29 test 30 sort 31 tar 31 nc 32 netcat 32 ls 34 cp 35 ifconfig 35 grep 36 date 43 find 50 sh 61 sed 93 And wince. Hmmm... there's sort of a "option modifies other option" thing with -s and -k and also -Cx and -w... Also, the logic of "what to show" vs "output formats" is that the first changes which data files and data fields get displayed, and the second is the same info presented differently (column sorted, one per line, comma separated, etc)... And that is NOT true of the -l -o -n and -g fields, which are in the <megamind>presentation</megamind> section but are actually field selection. All four of those are long mode variants with minor tweaks (I'm sure somebody intended having those four be -l synonyms as some kind of easter egg). Running ls by itself doesn't show date, size, owner, and permissions. Adding -l adds all that. Can I punt this to Julia Evans maybe? No? Sigh... Eh, checked in as is for now. Note: this isn't enough for QNX because -k sets it back to the default. MY default is 1024. QNX's default is 512. So you might want to tweak the -k help text line some more, and add some variant of if (FLAG(k)) TT.block_size = 1024; to ls_main(). Rob P.S. I'm still not calling it a kibibyte. _______________________________________________ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net