On 11/25/2012 03:17 PM, Pengyu CHEN wrote:
> Follow-up Comment #2, bug #37811 (project findutils):
> 
> Oh.. It's my fault to submit a bug without checking for some infomation first.
> Sorry to all.
> Well, still I believe it's better to use some alternative error message than
> saying `unknow argument'.

What about the following?

Have a nice day,
Berny

>From 3e3d398295ff78516fa9251e8a1857004caaf0ed Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <[email protected]>
Date: Mon, 26 Nov 2012 23:42:12 +0100
Subject: [PATCH] find: improve diagnostic for not built-in arguments of -type

* find/parser.c (insert_type): Instead of running into the
default case, output a more helpful diagnostic for arguments
not built into the program.
---
 find/parser.c |   32 ++++++++++++++++++++++++--------
 1 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/find/parser.c b/find/parser.c
index aa01253..1cead6c 100644
--- a/find/parser.c
+++ b/find/parser.c
@@ -2863,30 +2863,46 @@ insert_type (char **argv, int *arg_ptr,
          type_cell = S_IFREG;
          rate = 0.95f;
          break;
-#ifdef S_IFLNK
        case 'l':                       /* symbolic link */
+#ifdef S_IFLNK
          type_cell = S_IFLNK;
          rate = 0.1f;
-         break;
+#else
+         error (EXIT_FAILURE, 0,
+                _("Argument to -type not built-in: %c (symbolic link)"),
+                (*typeletter));
 #endif
-#ifdef S_IFIFO
+         break;
        case 'p':                       /* pipe */
+#ifdef S_IFIFO
          type_cell = S_IFIFO;
          rate = 0.01f;
-         break;
+#else
+         error (EXIT_FAILURE, 0,
+                _("Argument to -type not built-in: %c (pipe)"),
+                (*typeletter));
 #endif
-#ifdef S_IFSOCK
+         break;
        case 's':                       /* socket */
+#ifdef S_IFSOCK
          type_cell = S_IFSOCK;
          rate = 0.01f;
-         break;
+#else
+         error (EXIT_FAILURE, 0,
+                _("Argument to -type not built-in: %c (socket)"),
+                (*typeletter));
 #endif
-#ifdef S_IFDOOR
+         break;
        case 'D':                       /* Solaris door */
+#ifdef S_IFDOOR
          type_cell = S_IFDOOR;
          rate = 0.01f;
-         break;
+#else
+         error (EXIT_FAILURE, 0,
+                _("Argument to -type not built-in: %c (Solaris door)"),
+                (*typeletter));
 #endif
+         break;
        default:                        /* None of the above ... nuke 'em. */
          error (EXIT_FAILURE, 0,
                 _("Unknown argument to -type: %c"), (*typeletter));
-- 
1.7.7


Reply via email to