[hackers] [PATCH] find: Make parameter error messages more specific

From: Quentin Rameau <quinq_AT_fifth.space>
Date: Sun, 29 Oct 2023 12:46:47 +0100

Differenciate option operands from path operands
when an error is detected on the command line parameters.
---
 find.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/find.c b/find.c
index d4d7864..ef28232 100644
--- a/find.c
+++ b/find.c
_AT_@ -809,8 +809,12 @@ parse(int argc, char **argv)
 			}
 			tok->type = op->type;
 			tok->u.oinfo = op;
-		} else { /* token is neither primary nor operator, must be path in the wrong place */
-			eprintf("paths must precede expression: %s\n", *arg);
+		} else {
+			/* token is neither primary nor operator, must be */
+			if ((*arg)[0] == '-') /* an unsupported option */
+				eprintf("unknown operand: %s\n", *arg);
+			else /* or a path in the wrong place */
+				eprintf("paths must precede expression: %s\n", *arg);
 		}
 		if (tok->type != LPAR && tok->type != RPAR)
 			ntok++; /* won't have parens in rpn */
-- 
2.42.0
Received on Sun Oct 29 2023 - 12:46:47 CET

This archive was generated by hypermail 2.3.0 : Sun Oct 29 2023 - 12:48:35 CET