aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
AgeCommit message (Collapse)Author
2019-11-03id: support numeric lookup.Elliott Hughes
Fall back to converting the "name" to an integer and calling getpwuid(). We need to update `username` for the later call to getgrouplist(). Also fix the separator printing logic to avoid a trailing ',' on `id 0`. Switch to FLAG() and move some declarations down to where they can be initialized, both for clarity. Also add simple tests. Sadly, there's no always-present user that is in multiple groups.
2019-10-31ls: Remove trailing whitespace so that tests passAndrew Ilijic
When in modes `-C` and `-x` we need to remove the trailing whitespace on each line. This is the behavior of other `ls` commands. Other `ls` commands will print the last filename and then print a newline. Prior to this patch we would print the last filename, followed by two spaces, and then print a newline. Previously, we would get to the end of the loop and print the padding. I couldn't figure out a way to determine when the program had reached the end of a line. So I piggybacked off of the newline code.
2019-10-28ls: Add `-w` which sets the column widthAndrew Ilijic
2019-10-28Switch the fudge factor from 2048 to 4096 to unblock android build.Rob Landley
2019-10-28cp: treat a directory name with a slash at the end the same as one without a ↵William Haddon
slash
2019-10-28More xargs cleanup, with one possible accounting error but not what fixesRob Landley
the -0 "argument too long" issue.
2019-10-27Tar extract should delete files or symlinks where it's making a directory,Rob Landley
but --restrict checking should run on the path up to the last component before unlinking so tar can't be tricked into deleting random files off the system.
2019-10-26cut: re-enable crunch_str on cut -CJarno Mäkipää
Reason: unicolumns() does not print combining characters correctly Combining characters follow the character which they modify. https://www.cl.cam.ac.uk/~mgk25/unicode.html#comb xterm renders cut test1.txt -C -1 now correctly
2019-10-26Add ln -r and relative_path() to lib, plus test.Rob Landley
And a few small cleanups while I was there.
2019-10-24Fix the xargs argument too long problem by putting the proper accountingRob Landley
back when they haven't specified -s, add tests.
2019-10-22JakeSFR on github pointed out that broken symlink relative detection was beingRob Landley
checked relative to the current directory, not from where the symlink lives.
2019-10-21Use FLAG() macros more.Rob Landley
2019-10-21Remove getdirname(), it's _not_ a drop-in replacement for dirnameRob Landley
(it returns a malloc), and doesn't match the object lifetime of getbasename() (which always returns some or all of its argument string). The dirname() in libc modifies its argument string, but that's what posix says to do: https://pubs.opengroup.org/onlinepubs/9699919799.2008edition/functions/dirname.html so I guess we can live with it.
2019-10-21More xargs cleanup.Rob Landley
2019-10-21xargs: fix type of a local to avoid a cast.Elliott Hughes
2019-10-17ls: Ensure file names are separated by 2 spacesAndrew Ilijic
We need two spaces between filenames because that is the convention followed by other implementations. More importantly, if we do not have two spaces, certain Unicode file names cause filenames to run together. In Unicode, combining characters come before the character they modify. If a filename ends in a combining character, the combining character attaches to the space that follows it, causing the space not to be visible. Having a two-space gap stops the above issue from happening. For context and a bit more information, see mailing list link below. https://www.mail-archive.com/toybox@lists.landley.net/msg05986.html
2019-10-15In-passing cleanup and add a NOP -P.Rob Landley
2019-10-14Make cmp work with 1 argument (implicit - as second argument).Rob Landley
2019-10-12Don't need the second variable, and put the comment back.Rob Landley
2019-10-12Fix argless find segfault.Denys Nykula
Inline array becomes garbage outside the if.
2019-10-09xargs: various fixes.Elliott Hughes
Don't run the command with no arguments if we run out of input but have already run the command at least once. The implementation of "run the command at least once (unless -r was supplied)" wasn't taking into account whether or not this was our first time round the loop. Fix the exit value, and the -- already documented but not implemented -- behavior if a child exits with status 255. Also extend the tests to cover these cases, plus cases I broke while coming up with the fix. Add more tests to convince myself that we've correctly interpreted how -s is supposed to behave, and fix the corner cases at the bottom end of the range. This fixes some issues we were seeing trying to build the Android SDK for (and more importantly, on) macOS.
2019-10-09ls: fix seqfault on broken localeJarno Mäkipää
When user builds toybox CFG_TOYBOX_I18N disabled and tries to list folder contents with multibyte characters other than UTF-8 ls might seqfault since wcrtomb returns -1 while locale set to fi_FI-UTF-8 disable CFG_TOYBOX_I18N touch őőőőaaőő ls
2019-10-08Add arch command.Rob Landley
2019-10-04ln.c: add -t to synopsis.Elliott Hughes
We're inconsistent about whether the option help below should be just `-t` or `-t DIR`, but the majority of commands _don't_ repeat their argument, so I've left that as-is for now.
2019-10-04file.c: add -s to synopsis and fix case consistency.Elliott Hughes
2019-10-04Fix extracting old tarballs, not just -tv of them.Rob Landley
2019-10-03Improve support for extracting older tarball formats.Rob Landley
2019-10-01Add rmdir --ignore-fail-on-non-emptyEthan Sommer
2019-09-30Add ln -tEthan Sommer
2019-09-26Max 2 arguments with -TRob Landley
2019-09-25Add ln -TRob Landley
2019-09-25Use FLAG macrosRob Landley
2019-09-20rm.c: use FLAG().Elliott Hughes
2019-09-19Basename can have suffixes starting with a dash.Rob Landley
2019-09-18Fix tar creation with hole at end.Rob Landley
The "gratuitous extra entry" is only gratuitous when there isn't a hole. (Which we can detect and not include but then we wouldn't match other implementations.)
2019-09-17Implement -s.Rob Landley
2019-09-16Ahem, -newerXY is in _find_, not in _file_.Rob Landley
2019-09-16bug: tar tvf blah.tar.xz was running xz when it meant xzcat.Rob Landley
2019-09-15Fix failing test.Rob Landley
2019-09-15The ! changes I meant to check in last time were applied ot the wrong dir.Rob Landley
(oops.)
2019-09-15Fix tar files that end sparse (need to call truncate), and display/exportRob Landley
length of sparse files properly.
2019-09-14Add -newerXYRob Landley
2019-09-12Minor cleanup.Rob Landley
2019-09-11Add NOP -f, -g#, and --no-backup-if-mismatch options.Rob Landley
(All ignored, because they disable stuff we don't do.)
2019-09-11Add q123 exit code, add Q, fix "sed ' ! '" bad error message.Rob Landley
2019-09-09ls: fix spacing of -lZ and --full-time.Elliott Hughes
Two more spacing bugs here, one before the security context for -Z, and one after the size with --full-time. Before: $ ./toybox ls -lZ --full-time Config. -rw-r----- 1 enh primarygroup? 56162019-09-07 21:09:32.892215100 -0700 Config.in After: $ ./toybox ls -lZ --full-time Config. -rw-r----- 1 enh primarygroup ? 5616 2019-09-07 21:09:32.892215100 -0700 Config.in
2019-09-04find: support -printf \0 octal escapes and \c.Elliott Hughes
I think when I wrote this I tested the named escapes like \n and hex escapes, and when I found \x wasn't supported I didn't even think of octal. And I only learned about \c when I was looking at echo and printf to compare their escape implementations a few weeks back. Add the missing escapes and corresponding tests. Fixes #139.
2019-09-04ls: fix -Z, add a test.Elliott Hughes
This broke a netd test (but sadly in postsubmit rather than presubmit). Also add a trivial test that would at least have caught this bug. Bug: http://b/140453237
2019-09-04DIRTREE_STATLESS doesn't have to test 3 stat fields, it sets a flagRob Landley
2019-08-30ls: fix recent regression.Elliott Hughes
Commit c26870dab3462c6176936384b090df6b9ba46dee broke ls' error reporting for files that don't exist. `ls $F` is used by some as an equivalent of `test -e $F`. This patch also adds a regression test.