aboutsummaryrefslogtreecommitdiff
path: root/toys
AgeCommit message (Collapse)Author
2019-01-21Add more comments to ps.c and replace hardcoded value with a macro.Rob Landley
If table grows >64 entries XX needs to change, but it can't be 128 yet because the slot value is a signed char. Currently 59 entries in table...
2019-01-19hostname: fix behavior when in jail.Elliott Hughes
Only -d and -f should cause a DNS lookup. The rest should just act directly on the result of gethostname(3). Encountered with the AOSP buildbots' use of nsjail, but tested with both the Debian hostname and toybox hostname thus: ``` unshare -Uunr sh hostname android-build hostname hostname -s hostname -d hostname -f ``` (Not sure how to add that to the tests.) Also fix a SEGV with -s if the hostname doesn't contain a '.'. Also switch to the FLAG() macro. Also add the missing -s to the synopsis. Bug: http://b/123123255
2019-01-18xargs: make --help match reality.Elliott Hughes
Implement -p, -t, and -r. Add some missing tests. Move -L and -x back to TODO since they're not implemented and I haven't yet even understood what they're supposed to do.
2019-01-18First chunk of sntp code.Rob Landley
2019-01-16Move xsendto() to lib/net.c.Rob Landley
2019-01-14Minor cleanups to patch. (Mostly whitespace and brackets.)Rob Landley
2019-01-13Better support patching files with tabs in the name.Rob Landley
Patch dates are optional these days, and I should properly work back from the end and only peel off properly formatted tab+date, but "tab followed by digit" is probably good enough and nobody's ever complained about just tab. And we still don't support patching filenames with newlines in them...)
2019-01-12Fix cp permissions when copying symlink contents, and add test.Rob Landley
2019-01-12stat: add --format synonym for -c.Elliott Hughes
Used in the AOSP x86 host build.
2019-01-12sed: add -z.Elliott Hughes
Used to construct SELinux policies in the AOSP build. I left loopfiles_lines with its hard-coded '\n' because although cut(1) also has a -z option, I can't find any case where it's used in any of the codebases searchable by me. (And fmt(1), the other user, doesn't even have the option.) YAGNI. Bug: http://b/122744241
2019-01-12patch: add -s to the synopsis line and fix typos.Elliott Hughes
2019-01-11Fix b ending with }Rob Landley
For a definition of "fix" that's even _more_ of a deviation from posix, but matches what debian does...
2019-01-11patch: add -s/--quiet.Elliott Hughes
Used by AOSP build. Also switch to new FLAG macro. Bug: http://b/122739027
2019-01-08modprobe: don't return failure just because we didn't find global config.Elliott Hughes
Without this change, a successful modprobe on Android exits with status 1 because Android doesn't have /etc/modprobe.conf or /etc/modprobe.d/ --- neither of which seem to be required on desktop Linux either.
2019-01-08ls: Fix -t to also sort by st_mtim.tv_nsec.Peter Collingbourne
2019-01-08file: add riscv ELF machine.Elliott Hughes
It's in the Linux 4.20 kernel headers.
2019-01-08more: don't _exit(0) on success.Elliott Hughes
If we do, we won't flush, and we might not output everything.
2019-01-07modprobe: reset errno before ins_mod.Elliott Hughes
Otherwise in verbose mode we output bogus errors instead of `Success`.
2019-01-02Josh Gao said "netcat -l -p 12345" broke:Rob Landley
Previously, when trying to listen on a socket without using one of -4, -6, or -s, we tried to create an AF_UNSPEC socket, which fails.
2018-12-29Use FLAG() macros in ps.Rob Landley
2018-12-27ipv6 address didn't fit in the buffer.Rob Landley
2018-12-23Add grep --colorRob Landley
2018-12-21Fix UDP checksum verification error.Elliott Hughes
From RFC 768, if UDP packet checksum computation yields a result of zero, change it to hex 0xFFFF. The current udhcpc checksum verification would yield false positive for this case. A better way is to compute the checksum with the original checksum field and the result should be zero for good udp packet. Signed-off-by: Yangchun Fu <yangchun@google.com>
2018-12-19First stab at sort -VRob Landley
2018-12-19Fix sort -x attached to a key.Rob Landley
2018-12-19readlink: add --canonicalize synonym for -f.Elliott Hughes
Internally, Google uses all the longopts; Android currently only uses this one. I was tempted to add the others, but went with "add them when a toybox user needs them" rather than "add them when you've seen them used".
2018-12-19md5sum/sha1sum: add --status and --check, fix --check with multiple files.Elliott Hughes
Annoyingly coreutils and busybox both have the --status functionality, but coreutils only accepts --status and busybox only accepts -s. Although all extant users known to me use --status I've supported both (a) for maximum compatibility and (b) because Rob hates longopts :-) Also, -c/--check don't take argument(s): they alter the interpretation of all the FILE... arguments. I removed a bunch of dead code here, but I couldn't switch us over to loopfiles_lines because I didn't want to regress on the "warn if any check file contains no hashes", and loopfiles_lines doesn't give you any way to recognize that you've moved on to the next file.
2018-12-17Use FLAG() macros in grep.Rob Landley
2018-12-17A couple more grep tests, and slightly use dlist_terminate() for the loops.Rob Landley
2018-12-17Fix remaining grep_tests.Rob Landley
Handling -e by gluing together multiple regexes with | wasn't portable, break down and do a linked list with for loops.
2018-12-15Add sed -iEXT to keep backup files.Rob Landley
2018-12-11Implement --preserve default = mot behavior (fixes segfault when no argument).Rob Landley
2018-12-10nc: add UDP support.Josh Gao
2018-12-10nc: add IPv6 support.Josh Gao
2018-12-09Support embedded NUL bytes in grep output, and free memory leaked per-file.Rob Landley
2018-12-09More grep.tests: make exit code 2 happen when it should.Rob Landley
2018-12-09Fix first grep.test failure (-B + -b not producing middle field).Rob Landley
When necessary, realloc() the line to add 4 aligned bytes of storage at the end, stick the unsigned offset in there, and then fish it back out for display (and add 1 because offset is 0 based and display is 1 based).
2018-12-08Rikk on github asked for the examples back.Rob Landley
2018-12-07macOS: fix getconf(1) build.Elliott Hughes
Several parameters common on Linux are missing on macOS.
2018-12-07Fix mktemp to pass tests.Rob Landley
2018-12-04Add FLAG(x) macro, expanding to (toys.optflags & FLAG_##x)Rob Landley
2018-12-04Clean up some --help formatting.Elliott Hughes
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".
2018-12-04mktemp: more tests, more fixes.Elliott Hughes
I realized (after being questioned about my motivation) that I hadn't added a test for the -u behavior. Adding the missing test confirmed the usual "if there isn't a test, the code is broken", but now I think I actually understand how we're supposed to choose between DIR, $TMPDIR, and /tmp. I've added more tests to back this up, and rewritten the code one more time so that we pass all the tests.
2018-12-04Remove CFG_SORT_BIG, just always do that.Rob Landley
2018-12-03mktemp: fix warning with glibc 2.15.Elliott Hughes
Old versions of glibc had warn_unused_result on mktemp(3), despite it always returning its argument. Still, we can silence the warning and save a line, so...
2018-12-02Fresh implementation of test.c.Rob Landley
2018-11-30macOS: fix uname.Elliott Hughes
Don't hard-code Linux's buffer size.
2018-11-30Tweak comments.Rob Landley
2018-11-30macOS: move struct sysinfo out of GLOBALS.Elliott Hughes
Even if we don't build ps, we can't have a Linux-only struct in GLOBALS. The obvious alternative to this would be to have a fake struct sysinfo in lib/portability.h. Since having a real macOS replacement for sysinfo(2) seems unlikely at this point, I went this route instead.
2018-11-29Marius Adaskevicius pointed out mdev -s should follow symlinks.Rob Landley