Age | Commit message (Collapse) | Author |
|
This patch does two things:
1. Enable line buffering for echo and yes. I found this through test
flakiness from the toybox xargs tests running in CI on devices where
"echo" is provided by toybox. For `echo y`, GNU echo does one write
of "y\n" but toybox echo was doing two writes, which makes it more
likely (4% on the heavily-loaded CI machines) for writes from the two
processes to be interleaved.
2. Fix line buffering on glibc if you're calling `toybox foo` rather
than `foo`. Otherwise we come through once and switch to unbuffered
mode, then again and switch to line buffered mode --- which doesn't
seem to actually work in glibc unless you specify a buffer (so
passing toybuf and sizeof(toybuf) works, but NULL and 0 doesn't).
I hit the second issue trying to reproduce the first issue on the desktop
rather than on Android.
(If you're scratching your head wondering "why yes(1) too, not just
echo(1)?", that represents a blind alley I went down when I mistook
which tool was in use. It seemed like the same principle should apply,
and it matches what other implementations do.)
|
|
|
|
This only touches 24 of the 68 toys/posix/ files --- the others were
already canonical.
Potentially contentious, so worth stating explicitly, is that there
were 8 matches for "COMMAND..." amongst all existing help output,
with 7 matches for various inconsistent variants involving something
with "ARG", so I resolved that in favor of using "COMMAND..." (which
is also shorter overall, and avoids nested []s).
|
|
The behavior with "\xAV" (where the second hex digit is invalid) is
different from the behavior with "\xVA", and echo and printf differ from
each other.
|
|
A TOYFLAG_NOFORK command must run in the context of toysh, but a MAYFORK
can either run standalone or run in the toysh process. MAYFORK means it
cleans up after itself: no leaked resources (malloc, mmap, filehandles, etc),
even in error_exit() paths that would longjmp() back to the shell. It also
doesn't discard anything we need to retain (don't close stdout, change
toys.optargs[] so we can't free it, etc)...
|
|
|
|
POSIX finally gave us a way to use echo in a portable way despite
differences of opinion about whether to default interpretation of escape
sequences to on or off: -e enables and -E disables (as already
implemented by busybox and coreutils).
http://austingroupbugs.net/view.php?id=1222
|
|
|
|
Be consistent about upper versus lower case. (Upper seems to have the
majority, so I went with that, though I'm happy to provide the opposite
patch as long as we're consistent!)
Be consistent about using \t. (Though saving a few bytes seems like it
might be better done in the code that generates help.h rather than
directly in the source, since tabs make careful ASCII art layout hard
enough that we regularly have things misaligned.)
Remove trailing periods (most of which seem to have been added by me).
Always use the US "human readable" rather than my British
"human-readable", and be more consistent about declaring whether we're
showing multiples of 1000 or 1024.
Just say "verbose" rather than adding a useless "mode" or "output".
|
|
|
|
|
|
|
|
right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
The actual code should be the same afterward, this is just cosmetic refactoring.
|
|
FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
|
|
|
|
|