aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
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-18Add grep tests to "make tests".Rob Landley
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-17Only set FLAGS_NODASH when arguments didn't have a dash.Rob Landley
This (eventually) lets "ps ax" and "ps -ax" behave differently.
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-14Add xrename()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-07macOS: fix code using POSIX 2008 `st_[acm]tim` fields.Elliott Hughes
Hopefully they'll fix this properly at some point, but until then...
2018-12-07Forgot to check the portability.? changes. (Oops.)Rob Landley
2018-12-07Fix mktemp to pass tests.Rob Landley
2018-12-06mktemp: just the missing tests.Elliott Hughes
2018-12-05macOS: iconv(1) needs libiconv on the mac.Elliott Hughes
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-04macOS: move getmountlist.c functions into portability.c.Elliott Hughes
I think this was the preferred option for this code that turns out to be very different on Linux vs BSD. I don't yet have a BSD implementation, and I'm not likely to have chance to work on one in the near future, so this just #ifdefs it out for macOS right now. With this (and a suitably minimal .config), toybox builds for macOS out of the box.
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-04Also remove SORT_BIG from sort.test.Rob Landley
2018-12-04Remove CFG_SORT_BIG, just always do that.Rob Landley
2018-12-03Break runtest.sh out again: the Android devs were using it.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-02Teach testcmd to say short name rather than full path.Rob Landley
2018-12-02Merge runtest.sh into test.sh.Rob Landley
2018-12-02Fresh implementation of test.c.Rob Landley
2018-12-01Stop testing the shell builtin, test the actual command.Rob Landley
2018-11-30macOS: remove unnecessary <stdio.h> workarounds.Elliott Hughes
These were added in macOS 10.7 in 2011-07, so the seven year rule applies...
2018-11-30macOS: fix uname.Elliott Hughes
Don't hard-code Linux's buffer size.
2018-11-30Tweak comments.Rob Landley
2018-11-30macOS: Apple's ancient linker doesn't have --as-needed or --gc-sections.Elliott Hughes
2018-11-30macOS: work around header idiosyncracies.Elliott Hughes
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-30macOS: fix endian macros for macOS.Elliott Hughes
I've also flipped the `#if` because `#ifdef` feels more naturally readable than #ifndef when there's also a `#else`. (I've preserved the oddness of the clearenv declaration being here, because there isn't currently a more suitable `#ifdef __APPLE__` to move it too. Later...)
2018-11-29Marius Adaskevicius pointed out mdev -s should follow symlinks.Rob Landley
2018-11-29Remove an extra #include <string.h>Rob Landley
2018-11-29macOS: remove glibc 2.10 workarounds.Elliott Hughes
The only part of this I actually need for macOS is to remove __APPLE__ from the getdelim/getline workaround, but if we're following the usual "seven year rule", glibc 2.10 is dead to us anyway, and we should just remove all of this.
2018-11-28mktemp: add -t and fix behavior.Elliott Hughes
The new tests pass on the host (coreutils 8.28) and with toybox after this patch is applied.
2018-11-28macOS: there's no <features.h> on the Mac.Elliott Hughes
2018-11-28macOS: replace local strnstr with strcasestr.Elliott Hughes
bionic, glibc, macOS, and musl all have strcasestr (see http://man7.org/linux/man-pages/man3/strstr.3.html). macOS (via BSD) has a strnstr that does what strnstr sounds like it should do by analogy with strnlen and strncpy. So we at least need to rename strnstr, but it probably makes more sense just to switch to strcasestr instead.
2018-11-28macOS: noreturn.Elliott Hughes
The macOS libc headers use `__attribute__((noreturn))` rather than `__attribute__((__noreturn__))`, so toybox's `noreturn` macro trips them up. Since we already have a variety of uses of `__attribute__` that aren't guarded in this way, let's do the same here.
2018-11-28macOS: use -E rather than -r for sed extended regular expressions.Elliott Hughes
GNU sed supports -E, -r, and --regexp-extended. BSD sed only supports -r.
2018-11-28head: add --bytes synonym for -c.Elliott Hughes
Used by OTA package scripts in AOSP, and quite widely inside Google. I've also added --lines because it seems crazy to support one and not the other, and --lines is also widly used inside Google too.
2018-11-26file: small do_regular_file optimizationReverend Homer
There are a bunch of if (!memcmp(s+28,...)) lines, let's make them "else if"