aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
AgeCommit message (Collapse)Author
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
2019-03-04Don't print (null) in error messages.Rob Landley
2019-03-02Make top -H show TID instead of PID, not collate %CPU into parent threadRob Landley
(resulting in 400% CPU with 4 threads), and add a couple comments.
2019-03-02Improve help consistency.Elliott Hughes
More consistent tense, capitalization, and punctuation. A few commands were missing an introductory line, so I copied those from the first comment line.
2019-03-01Yes it's a one instruction race, but it bothers me.Rob Landley
2019-02-27top: fix -b.Elliott Hughes
We hadn't updated the output in -b mode ever since I broke this in 2016. Bug: http://b/126347053 "top doesn't seem to update the output when run in batch mode (-b)"
2019-02-24grep: add missing long synonyms used in AOSP.Elliott Hughes
2019-02-23Bumper typo cleanup.Elliott Hughes
Inspired by some of the small patches that have gone by recently. Limited to only things found in `generated/help.h`, plus a wider cleanup for the more common "milisecond" typo.
2019-02-19grep: add --quiet and --silent synonyms for -q.Elliott Hughes
--quiet is used 3x more than --silent in my corpus, but they're both used surprisingly often. (Surprising to someone who thinks -q is part of the core set of grep options that "everybody knows".)
2019-02-17top: make the task/thread count add up.Elliott Hughes
Linux has more states than we were giving it credit for, which led to our numbers not adding up. Since the exact details seem to change between versions, and since having code specific to each kernel version is unattractive, go with the heuristic that there are relatively fewer "stopped" states (and they change less frequently), so all unknowns are "sleeping".
2019-02-16Disallow -o "" in top.Rob Landley
2019-02-16top: differentiate tasks (processes) and threads in the header.Elliott Hughes
2019-02-16top: make the column header span the terminal.Elliott Hughes
This also makes everything more readable by separating out the -b no formatting case. The whitespace trimming for -b isn't strictly necessary, but it looks weird if we output unnecessary spaces at the end of the line in -b mode, and we've fixed it before, so let's not regress here. It also seems more logical to do this in the one place where it actually happens.
2019-02-15Fix typos: e.g. change "cannonical" to "canonical".Jason Spiro
2019-02-14Use current time for unspecified fields, set weekday to match date.Rob Landley
2019-02-13top: support Enter as a synonym for Space.Elliott Hughes
Both refresh the display in the traditional implementation.
2019-02-13top: use human_readable for the header lines too.Elliott Hughes
Even phones have enough RAM these days that KiB is not a reasonable unit. Traditional top always uses MiB instead of always using KiB, but we may as well just let human_readable pick a unit (that way if KiB is reasonable on your box, that's what you'll get). Before: Tasks: 967 total, 1 running, 581 sleeping, 0 stopped, 0 zombie Mem: 196734820k total,183891564k used, 12843256k free, 5805008k buffers Swap:199888892k total, 719104k used,199169788k free,130367280k cached After: Tasks: 965 total, 2 running, 577 sleeping, 0 stopped, 0 zombie Mem: 188G total, 175G used, 13G free, 5.5G buffers Swap: 191G total, 702M used, 190G free, 124G cached
2019-02-13top: hide the cursor in interactive mode.Elliott Hughes
Matches traditional top.
2019-02-13find: fix -path/-ipath and add -wholename/-iwholename synonyms.Elliott Hughes
Plus new tests.
2019-02-13sed: fix endless loop in "b loop" test.Elliott Hughes
Very few places actually check for errors from emit, and I actually see the same endless loop from "sed (GNU sed) 4.4" on current Debian, so I'm not sure this isn't Broken As Designed, but an endless loop spewing "short write" (or saying nothing, in the case of GNU sed) really doesn't feel like useful behavior in face of EPIPE, which really isn't going to fix itself. Certainly not being able to run the sed tests to completion is pretty annoying --- which is why, unless we remove this test as invalid, we should probably also add a SKIP_HOST=1 to the "b loop" test. Note that even with this fix you'll see the error twice: sed: short write: Broken pipe sed: short write: Broken pipe Once from the first = command to fail, and then another from the !FLAG(n) flush of the pattern space.
2019-02-12sed: fix substitution of empty capturing groups.Elliott Hughes
The test for \N where N was larger than the number of capturing groups in the regular expression was incorrect, and firing for cases such as matching __(ARM_)?NR_([a-z]*) against __NR_read, where the first group is empty (because it failed to match) but the second group did match "read". Use regex_t's re_nsub for the error check, and treat rm_so == -1 as a signal to just copy nothing into the result. (Found trying to build minijail in AOSP.)
2019-02-11date: some fixes.Elliott Hughes
Add support for more input formats, primarily the ISO formats used by the AOSP build. I've improved/added to the tests a bit to cover these changes, and to explain the reasons for the various remaining test failures (none of which are regressions caused by this patch).
2019-02-07ps, top: fix VIRT and SHR fields.Elliott Hughes
2019-02-04sort -o: fix behavior when output file is one of the input files.Elliott Hughes
Bug: http://b/123902291
2019-02-04who: make the output more like coreutils who.Elliott Hughes
Also add a TODO for the (undocumented, half-finished) -a option.
2019-01-31Sed assumed FLAG(r) was 1 but didn't document it above the NEWTOY line. (oops)Rob Landley
2019-01-25OpenEmbedded needs commands installed in specific places.Rob Landley
2019-01-24grep: "tried" should track arguments (not files) that existed, move -o "" testRob Landley
into display function, use unsigned length so output lines can be up to 4g each.
2019-01-22Whitespace: remove tabs from indentation.Elliott Hughes
I accidentally added a tab in xargs.c, so as penance I'll clean up all the tabs.
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-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.