aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/find.c
AgeCommit message (Collapse)Author
2023-10-01Set DIRTREE_SYMFOLLOW when we followed a symlink to this node.Rob Landley
(Mask out the bit in callers that just want DIRTREE_COMEAGAIN.)
2023-05-03Fix error reporting for find -commands that take an argument butRob Landley
haven't got one because they're at the end of the command line. This unknown commands, because the logic is an if/else staircase handling commands that reaches an "else { everything after here takes an argument" that pops the argument, then has an eventual else goto error; for unknown commands. Since argv[] always ends with a NULL pointer, we were trying to print that in the error message.
2023-02-26Reorder find help text so match filers that take an argument are mostly inRob Landley
the left column, and while I'm there move -quit to "Actions" because it is, then implement -readable to fill in the hole in the right column that left.
2023-01-20Switch dirtree to set macro bits instead of hardwired numbers.Rob Landley
2023-01-18Fix help text.Rob Landley
2022-09-14Fix spellingAntoni Villalonga
2022-06-29Add same_file() and same_def_ino() convenience functions, plus minor cleanups.Rob Landley
2022-02-07Fix -newerXY and add test.Rob Landley
2021-12-09Add -samefile, collate help text, cleanup, update tests.Rob Landley
2021-09-06Add find -lname -ilname and -d as a synonym for -depth.Rob Landley
2021-05-26Add find -quitRob Landley
2021-02-14Add find -executableRob Landley
Requested by aheirman on github: uses access(X_OK) which checks access control lists as well as permissions, and that _we_ can access them (u+x could be owned by a different user)...
2020-12-05Fix find empty argument handling and add test.Rob Landley
2020-07-30Don't need "match", just test *t.Rob Landley
2020-07-30find: support -type a,b,c.Elliott Hughes
Fixes #227.
2020-04-13Add unescape2(), migrate some unescape() users over.Rob Landley
2020-01-11find.c: don't assume time_t is the same as longRich Felker
This is false on ILP32 targets with 64-bit time_t.
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-09-16Ahem, -newerXY is in _find_, not in _file_.Rob Landley
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-04DIRTREE_STATLESS doesn't have to test 3 stat fields, it sets a flagRob Landley
2019-08-30find: fix -name corner case.Elliott Hughes
This fixes the case where someone's done something (weird) like: find src/*.c -name foo.c Previously the match would fail because one side of the comparison was already a path.
2019-08-28Fix find(1) after c26870dab346.Elliott Hughes
Unlike ls, find does treat ENOENT specially. Add an extra test (and fix the behavior) for the case of ENOENT for a path provided on the command line --- unlike other ENOENT cases (typically dangling symlinks), ENOENT for a command line argument should report an error. Also remove obsolete `|sed` from the symlink loop test.
2019-08-09find: fix dangling symlink behavior.Elliott Hughes
ENOENT is ignored, but other errors are reported.
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-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-05-29Teach find -printf about %.Ns patterns, tweak help text, add tests.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-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-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-02-13find: fix -path/-ipath and add -wholename/-iwholename synonyms.Elliott Hughes
Plus new tests.
2018-10-27Zach Van Rijn asked for "find -empty".Rob Landley
2018-08-19Comment tweak.Rob Landley
2017-11-21Make find -exec + obey ARG_MAX just like xargs.Elliott Hughes
This isn't ideal, but it matches xargs and none of us is likely to have time to do the best possible thing any time soon. Bug: http://b/65818597 Test: ./toybox find /usr/local/google/ndkports/ -exec echo {} +
2016-12-20Add units for -atime and friends. (Also legacy -amin alias, but not in help textRob Landley
because there's no -asec or -ahour.)
2016-08-18Change xgetpwnamid/xgetgrnamid to xgetuid/xgetgid returning the id numberRob Landley
instead of a struct. This means it can return "12345" even if that user/group doesn't exist in /etc/passwd and similar. All the users were immediately dereferencing it to get pw_uid or gr_gid anyway, so just return it directly and adjust the users. This fixes things like "chown 12345:23456 filename".
2016-08-04Make xopen() skip stdin/stdout/stderr, add xopen_stdio() if you want stdout,Rob Landley
add xopenro() that takes one argument and understands "-" means stdin, and switch over lots of users.
2016-07-12Implement NOP find -noleafRob Landley
2016-05-20Add bufgetgrgid()Rob Landley
2016-04-25Fix find bug reported by Tom Marshall, add test for it, and while we're at itRob Landley
fix two tests looking for a too-specific error message (so TEST_HOST failed).
2016-03-07Cleanup pass on the dirtree infrastructure, in preparation for making rm -rRob Landley
handle infinite depth. Fix docs, tweak dirtree_handle_callback() semantics, remove dirtree_start() and don't export dirtree_handle_callback(), instead offer dirtree_flagread(). (dirtree_read() is a wrapper around dirtree_flagread passing 0 for flags.)
2016-02-05Another fix from Josh Gao to avoid a null pointer dereference, andRob Landley
minor cleanup of previous commit.
2016-02-05Fix segfault when `find -iname` gets no argument.Josh Gao
2016-02-01Add find -deleteRob Landley
2016-01-14Make "find -execdir toys echo {} +" batch correctly and show topdir results.Rob Landley
I dunno if find -execdir should show depth-first like it's doing, bit given that ubuntu's treating "+" and ";" the same for execdir... eh? Also, testing "find toys tests -mindepth 2 -execdir echo {} +" against the toybox source is easy (and why if (revert) fchdir() is needed), but adding that to the test suite means making a nontrivial hierarchy of files to test against (don't wanna use the project source because it's expected to change in ways that would break the tests)... The old "real world data vs test data" problem.
2016-01-05Work towards making "find . -execdir echo {} + -execdir ls {} +" work,Rob Landley
(not finished yet) plus some error message improvements.
2016-01-02Fix find --prune.Rob Landley