aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
AgeCommit message (Collapse)Author
2019-07-06file: fix xz, add a few other Android types.Elliott Hughes
"xz compressed data" was missing a newline. Also switch a couple of other unnecessary (but correct) xprintf calls over to xputs. Also add .otf fonts, perf/simpleperf data files, and Android boot images, sparse images, and device tree blobs/overlays.
2019-07-06Add comment and test.Rob Landley
2019-07-06Have env exec, not recurse to builtin.Denys Nykula
My app runs npm i -S better-sqlite3, and node-gyp-bin from the npm upstream has #!/usr/bin/env sh, expecting the system shell.
2019-07-03nl: nl -vEric Molitor
Implement nl -v supporting negative and zero starting values.
2019-06-28file, stat: various small improvements.Elliott Hughes
file now shows the target of a symbolic link and calls out broken symbolic links. file now shows the device type for block/character special files. file now shows specific reason when it can't open. stat now includes the device type, plus a little more space between the number of blocks and the human-readable file type. Adjusted tests accordingly, which actually makes more of them pass on the host as a convenient side-effect, but I actually made these changes because I've been finding the desktop file and stat output more convenient in these cases.
2019-06-25tar: implement --mode.Elliott Hughes
Used by build/make/tools/mktarball.sh in AOSP. (Which is why today's switch to toybox tar got reverted.)
2019-06-23Switch cp.c to FLAG() macros.Rob Landley
2019-06-22Use FORCE_FLAGS in kill.c.Elliott Hughes
Otherwise kill flags don't work unless killall5 is also configured. Also switch to the FLAG() macro.
2019-06-22Fix mv with trailing slash in source.Denys Nykula
Press tab, have bash complete dir name with a slash, notice musl rename() dislikes that. Replace trailing slash in the cp loop with a null character, if the command name is mv. Add the slash back if an error occurs.
2019-06-21Fix cp -r dir/. symlink child.makepost
Remove the existing link before trying to re-create, passing the test. Add -p to the -r test as a regression guard, portage calls cp with both.
2019-06-11find: add -true/-false.Elliott Hughes
Used near the end of the AOSP build. Almost there! (This patch also fiddles with the help text to be able to slip the new options in without requiring so much extra space.)
2019-06-10Improve signal name<->number conversions.Elliott Hughes
Include all the signals, not just the POSIX ones. In particular, improve support for real-time signals. My attempt to switch AOSP builds over to toybox timeout got reverted when I broke the ART build bots which use SIGRTMIN+2. Also fix `kill -l 3` to show "QUIT" and `kill -l QUIT` to show "3". Also make the `kill -l` output include numbers and names, and format it to look better on a 80x24 tty, because it's always August 1978 somewhere.
2019-06-08macOS: numerous fixes.Elliott Hughes
This patch adds a BSD version of xgetmountlist (for the path == NULL case only), tested on macOS. It also papers over the differences between macOS' and Linux's xattr APIs. For once I think the macOS one is better. The imitation of mknodat I've had to write swings things back in Linux's favor though. BSD calls f_frsize by the name f_iosize instead. (FWIW, it looks like this is meaningless on Linux and actually meaningful on macOS.) I've added one #if to toys/ --- I'm calling pathconf in stat.c to work around the absence of f_namelen, and have left a TODO with an explanation. I'm not sure what the best fix is here, so punting. No-one can agree what f_fsid is, even if they're all basically the same, so work around the `val` versus `__val` issue between macOS and Linux. With this patch, it's now possible to build cp/mv/install and stat for macOS too. (Which completes the set of "toybox commands currently used on Linux as part of the AOSP build" if you ignore stuff that deals with processes, which I doubt we'll ever be able to support for lack of any API.)
2019-06-07Implement stat %C and find %Z.Elliott Hughes
We'd documented find %Z but not implemented it. We'd neither documented nor implemented stat's corresponding %C (they'd already taken %Z for ctime, which is ironic because %c/%C sounds more obvious than %z/%Z for that to me).
2019-06-03Remove TAIL_SEEK config option, just always include it.Rob Landley
Yeah, it's twice the size and two codepaths, but seekable is the common case, it won't work in pipelines without a non-seek codepath, and the performance penalty not using seek on large files is a enormous.
2019-06-01Teach file to recognize xz archives and old style tarballs.Rob Landley
2019-06-01Teach tar to extract older tarballs.Rob Landley
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