[Toybox] [PATCH 1/2] pgrep: Complain about invalid options
Brian Norris
briannorris at google.com
Wed Feb 5 10:21:10 PST 2025
pgrep will silently eat unknown args and treat them as process filters.
This is especially confusing for unimplemented options, like "-a".
If one needs to filter on a flag-like filter, there's always a "--"
separator, like:
pgrep -- -process-with-dashes
---
toys/posix/ps.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/toys/posix/ps.c b/toys/posix/ps.c
index 87dc1af4a9c6..3a745321c794 100644
--- a/toys/posix/ps.c
+++ b/toys/posix/ps.c
@@ -51,7 +51,7 @@ USE_PS(NEWTOY(ps, "k(sort)*P(ppid)*aAdeflMno*O*p(pid)*s*t*Tu*U*g*G*wZ[!ol][+Ae][
// the default values are different but the flags are in the same order.
USE_TOP(NEWTOY(top, ">0O*h" "Hk*o*p*u*s#<1d%<100=3000m#n#<1bq[!oO]", TOYFLAG_USR|TOYFLAG_BIN))
USE_IOTOP(NEWTOY(iotop, ">0AaKO" "Hk*o*p*u*s#<1=7d%<100=3000m#n#<1bq", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_STAYROOT))
-USE_PGREP(NEWTOY(pgrep, "?cld:u*U*t*s*P*g*G*fnovxL:[-no]", TOYFLAG_USR|TOYFLAG_BIN))
+USE_PGREP(NEWTOY(pgrep, "cld:u*U*t*s*P*g*G*fnovxL:[-no]", TOYFLAG_USR|TOYFLAG_BIN))
USE_PKILL(NEWTOY(pkill, "?Vu*U*t*s*P*g*G*fnovxl:[-no]", TOYFLAG_USR|TOYFLAG_BIN))
config PS
--
2.48.1.362
More information about the Toybox
mailing list