aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
AgeCommit message (Collapse)Author
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
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