[Toybox] People being confused by the existence of octal.

Rob Landley rob at landley.net
Sat Nov 16 15:54:14 PST 2024


Over on microsoft github, https://github.com/landley/toybox/issues/527 said:

   $ umask
   0022
   $ test $(umask) -eq 22
   $ echo $?
   0
   $ toybox test $(umask) -eq 22
   $ echo $?
   1

Where uname is returning octal (because file permissions are octal) so 
it's comparing an octal number vs a decimal number and my test is 
technically doing the right thing, but A) doing the right thing is 
confusing people, B) the "test" implementations in bash, coreutils, and 
busybox consistently get it wrong in the same way.

People being confused by the existence of octal has been reported before 
(in sed and such), and my complaint has always been that I'm as 
interested in the behavior being CONSISTENT as "right".

I'm tempted to switch atolx() default behavior to just hex or decimal 
and NOT do octal, because octal confuses people... except it IS used in 
a few places, ala printf '%d\n' 034 printing 28 
(<strike>Taylor's</strike> Debian's version). I suspect I'd need to 
audit all the users (around 85 at the moment)...

Anybody have a strong opinion on whether I should change the default? 
Changing the default mostly affects command line parsing for things like 
"truncate -s 077777" which it seems unlikely anyone is doing anyway?

Looks like I have a few whack-a-mole cases either way because the 
inherited environment we're trying to be compatible with isn't 
consistent, and trying to MAKE it so means I'm not compatible with 
what's there which is itself inconsistent...

Rob

P.S. it's a pity things things like "official posix compliance tests" 
stopped mattering 30 years ago when they cost an arm and a leg and Linux 
officially went "nah, we're good, if it's not published free on the web 
it's not a standard, go do your fortune 500 fundraising elsewhere". 
(That was back in the 90s, modern google can of course no longer find 
it. I could dig though the lwn.net annual summaries but eh...) These 
days, the IDEA of posix publishing a useful automated test suite is so 
blisteringly irrelevant that 
https://www.opengroup.org/testing/testsuites/posix.html has a big link 
to posixcertified.ieee.org which no longer has a DNS entry, and if you 
dig further you can manage "this https used such an old certificate it's 
not even TLS 1.2 which came out in 2008". Sigh...


More information about the Toybox mailing list