aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
AgeCommit message (Collapse)Author
2019-05-29Teach find -printf about %.Ns patterns, tweak help text, add tests.Rob Landley
2019-05-26Teach sed about +N range ending.Rob Landley
2019-05-25find: add -printf support.Elliott Hughes
This only implements the format specifiers that I've seen used in the wild (which is actually a significant fraction of the total supported by findutils' find). The most obvious gap is in the time support. I'm happy to add more, but didn't want to add stuff "just because". I'd say %A@, %C@, and -- for SELinux users -- %Z are probably the most plausibly useful formats still missing. I don't think the human-readable date formatting is particularly useful unless someone's seen it actually used in the wild. The %T+ "full ISO" format being the most likely exception to that. Anyway, this is enough for me get started building AOSP with toybox find.
2019-05-25grep: add --exclude-dir.Elliott Hughes
Used quite a lot, especially with `--exclude-dir=.git`.
2019-05-25time: fix -v output.Elliott Hughes
Copy-and-paste mistake from the regular output. Bug: http://b/133502489
2019-05-25Move notify.c into portability.c (collate the #ifdefs), move global variablesRob Landley
into a structure passed as arguments, add x prefix to functions that can fail, add overflow test.
2019-05-25tail: support -f on BSD too.Elliott Hughes
Factor out the inotify code and add a kqueue equivalent. Specifically tested on macOS 10.14, but I assume this works for other BSDs too, given that I worked from the FreeBSD man page...
2019-05-25Toybox doesn't provide bzip2 or xz compression side (and the roadmap has it asRob Landley
out of scope), but the AOSP build airlock doesn't provide bzcat and friends. So tar needs to be able to use both: check for *zcat first, and fall back to "compressor -d" if it's not there.
2019-05-23tar: turns out --sparse is also known as -S.Elliott Hughes
Found trying to build the aosp_cf_x86_phone-userdebug target. The good news is that the targets that I knew were using tar with sparse files all pass now.
2019-05-20Less incomplete tar help text.Rob Landley
2019-05-19Fix tar sparse extract with extension blocks.Rob Landley
2019-05-19Fix tar --sparse generation of extension block.Rob Landley
2019-05-19Add pointless trailing --sparse entry for exact binary compartibility.Rob Landley
There's no possible use for this, but debian's tar produces it, so...
2019-05-19Add --sparse file creation support to tar.Rob Landley
And fix tar cv to produce output to stderr when archive going to stdout.
2019-05-17Fix a missing else, and an inverted test hidden by the missing else.Rob Landley
Add test to show failure case.
2019-05-16Have ps.c human_readable fields use all the available space.Rob Landley
2019-05-16Use the space reserved in the header to display more precision.Rob Landley
2019-05-16Minor code shrink.Rob Landley
2019-05-14Checked in a debugging printf. Oops.Rob Landley
2019-05-14Typo caused a segfault. (Oops.)Rob Landley
2019-05-13Use FLAG() macros in lsRob Landley
2019-05-13Fix a couple error paths that don't continue archive create/extract properly.Rob Landley
2019-05-11Teach tar to extract type 'S' sparse file headers.Rob Landley
2019-05-06Round allocation up to page size so s/x/yy/g thrashes less.Rob Landley
And remove a "nine princes in amber" themed name I missed.
2019-05-04Optimize s//g to avoid fresh strdup/free of entire line for each match.Rob Landley
Instead have one target string and fill it out from start to finish writing to each location once.
2019-05-01tar: use same tools for decompression as for compression.Elliott Hughes
This is what GNU tar does, so Android's build system jail allows bzip2, gzip, and xz, but not bzcat, zcat, and xzcat. Why the function? Because auto-detection works by setting toyflags, so we need to make sure we test the flags late, so it's either two copies of this or a function.
2019-04-30Make echo -E switch off -e.Rob Landley
2019-04-30echo: add -E.Elliott Hughes
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
2019-04-26file: fix ELF note parsing.Elliott Hughes
Commit 9448c33944651c1644ffbd0f52cf9d43cae19599 broke ELF note parsing, because the bounds checking was off. Fix that but also generalize it so that we won't need note-specific bounds checking in future.
2019-04-21Promote tar.Rob Landley
There's probably more to do, but it seems usable at this point.
2019-04-20Add xunsetenv() for the error checking.Rob Landley
2019-04-20New xsetenv() plumbing (repeatedly set same environment variables withoutRob Landley
leaking memory), and mod env command to test it.
2019-04-18Ignore --line-buffered argument for script compatibility (it's the default).Rob Landley
2019-04-16Add argument to xflush() so it can test for stdout err without flushing.Rob Landley
2019-04-02Help text tweak.Rob Landley
2019-03-27Change fileunderdir() to return abspath to file.Rob Landley
2019-03-26Make touch use xparsedate() (result: -t and -d the same, autodetects format),Rob Landley
and fix tests to pass on host too.
2019-03-25Add rm -v.makepost@firemail.cc
Gentoo removes verbosely when building packages, for example vim-core: https://github.com/gentoo/gentoo/blob/665eaa8/app-editors/vim-core/vim-core-8.1.0648.ebuild#L120 Implement like toy cp, without prepending an escape sign to quotation marks in filenames. Document in a test this difference from coreutils but similarity to busybox. How do other implementations handle such escapes? If it matters, would you approach it with a loop and multiple prints or somehow else? Short help description follows 141a075, consistent with other commands.
2019-03-25find: fix inverted -exec exit statusVidar Holen
The return value of -exec was the command's exit code, which did not account for the fact that an exit code of zero means success, while in C, zero means failure. From POSIX: > the primary shall evaluate as true if the utility returns a zero > value as exit status This commit flips the return value, and adds two tests.
2019-03-24Factor out xparsedate() and xvali_date() into lib.Rob Landley
2019-03-18cmp/env/nice/nohup/sort: use TOYFLAG_ARGFAIL.Elliott Hughes
Also be a bit more consistent about `COMMAND [ARG...]` in usage text.
2019-03-18Document the -k2.3,4.5 syntax and make it behave closer to the other one.Rob Landley
2019-03-14grep: use TOYFLAG_ARGFAIL for grep too.Elliott Hughes
Also add a test, and add a test for timeout now it's been fixed.
2019-03-13date: fix various time zone/daylight time issues.Elliott Hughes
Sunday's transition in the US broke a bunch of the tests. Worse, it broke some of the QA folks' scripts. Finally, the boil that is date's handling of time zones and daylight time has come to a head... This patch fixes the newly-failing tests *and* the other tests that were checked in failing to serve as TODOs. I've resolved the test TODOs about whether implied year/century in POSIX format should mean the current year or 1900 in favor of the current year. Both busybox and coreutils agree, and Rob fixed the code recently so toybox agrees too, but without fixing the tests. I've switched tests from Europe/London to Europe/Berlin to avoid disagreements between C libraries about whether to say "GMT" or "UTC" when daylight savings is not in force. The majority of this patch implements what I'd been unsuccessfully trying to explain on the list: that to correctly implement the distinct input and output time zones (as demonstrated in the three failing tests we've been carrying around for a while), we should switch to working with time_t internally rather than struct tm. I've also added the code to temporarily switch to the input time zone (and back again). All the tests now pass.
2019-03-13Use defined constants for mkpathat.Hadrian Węgrzynowski
2019-03-10timeout: --foreground, --preserve-status, and --signal.Elliott Hughes
--signal is simply a synonym for the exiting -s. --foreground disables functionality we didn't yet have: putting the child into a new process group. I've added the functionality and the flag to disable it. --preserve-status also makes it clear that our exit statuses didn't match the coreutils version. In addition to callers that use --preserve-status to get away from this madness, I also have callers that check for specific exit values. This patch implements --preserve-status but also fixes all the other exit statuses. (The "125" exit value is broken for toybox in the same way that `toybox grep --whoops ; echo $?` is. To fix this, we'd need some way to signal that command-line parsing failures should exit with a different value than the usual 1 --- 2 for grep, 125 for timeout. I've done as much as grep manages, and left a TODO.) Also add timeout tests. I couldn't think of an easy test for --foreground, so I tested that manually with strace. Also add some newlines to the `toybox --help` output to make it easier to find the different sections, and expand the section on durations to call out that fractions are supported as a matter of policy. As long as timeout and sleep have text describing the duration syntax, make them the same. (Personally I'd remove both in favor of the `toybox --help` output, but as long as they're duplicated, keep them consistent.) Also remove the SLEEP_FLOAT variant --- xparsetime means that sleep no longer requires floating point to support sub-second resolution.
2019-03-10find: minor whitespace cleanup.Elliott Hughes
2019-03-10find: improve -context behavior on failure.Elliott Hughes
2019-03-09find: add -context.Elliott Hughes
Tested manually on an Android device with: adb shell find /system -context u:object_r:wait_for_keymaster_exec:s0 adb shell find /system/bin -context '"*key*"' adb shell find /system/bin -context '"*tool*"'
2019-03-09file: add c-sky ELF machine.Elliott Hughes
It's in the Linux 5 kernel headers. If, like me, you'd never heard of it: https://www.phoronix.com/scan.php?page=news_item&px=C-SKY-Approved-Last-Arch