From 5194d4ad66ad130cb730e0b192ba1e2b5181184d Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 11 Jul 2019 12:22:31 -0700 Subject: grep: add -R as well as -r. On BSD these are actually the same, and there's a -S that you need in addition. So strictly this is a behavior change for Android (which is going from BSD grep to toybox grep), but it's a behavior preserving change for the AOSP build (which is going from GNU grep to toybox grep), and the latter actually has a checked-in use of -R where the former doesn't. --- toys/posix/grep.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'toys') diff --git a/toys/posix/grep.c b/toys/posix/grep.c index 30a98190..b92294ed 100644 --- a/toys/posix/grep.c +++ b/toys/posix/grep.c @@ -10,7 +10,7 @@ * echo hello | grep -f st.st_mode)) { for (al = TT.exclude_dir; al; al = al->next) if (!fnmatch(al->arg, new->name, 0)) return 0; - return DIRTREE_RECURSE; + return DIRTREE_RECURSE|(FLAG(R)?DIRTREE_SYMFOLLOW:0); } if (TT.S || TT.M) { for (al = TT.S; al; al = al->next) @@ -464,6 +465,8 @@ void grep_main(void) TT.grey = "\033[0m"; } else TT.purple = TT.cyan = TT.red = TT.green = TT.grey = ""; + if (FLAG(R)) toys.optflags |= FLAG_r; + // Grep exits with 2 for errors toys.exitval = 2; -- cgit v1.2.3