Improve error message for find -type X (X = an unknown file type).

* find/parser.c (insert_type): Give a more comprehensible error
message when the type letter following -type or -xtype corresponds
to a type of file which was unknown on the system which compiled
the find binary.
* NEWS: Mention this improvement.
This commit is contained in:
2012-11-27 00:01:42 +01:00
committed by James Youngman
parent 14adbdd321
commit 74db15e221
3 changed files with 45 additions and 8 deletions

View File

@@ -1,3 +1,12 @@
2013-03-24 Bernhard Voelker <mail@bernhard-voelker.de>
Improve error message for find -type X (X = an unknown file type).
* find/parser.c (insert_type): Give a more comprehensible error
message when the type letter following -type or -xtype corresponds
to a type of file which was unknown on the system which compiled
the find binary.
* NEWS: Mention this improvement.
2013-03-24 James Youngman <jay@gnu.org>
Fix Savannah bug #38583: errno-buffer read failed in xargs_do_exec

8
NEWS
View File

@@ -2,6 +2,14 @@ GNU findutils NEWS - User visible changes. -*- outline -*- (allout)
* Major changes in release 4.5.12-git, YYYY-MM-DD
** Documentation Changes
If you use -type or -xtype with a type letter corresponding to a file
type which is not supported by the system on which find was compiled,
find will now give a clearer error message (though the functionality
is unchanged). Type letters are affected are D, l and p (for Solaris
Doors, symbolic links and named pipes respectively).
** Bug Fixes
Some bugs in 4.5.11 were fixed without addinng them to the bug

View File

@@ -2863,30 +2863,50 @@ 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,
_("-type %c is not supported because symbolic links "
"are not supported on the platform find was compiled on."),
(*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,
_("-type %c is not supported because FIFOs "
"are not supported on the platform find was compiled on."),
(*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,
_("-type %c is not supported because named sockets "
"are not supported on the platform find was compiled on."),
(*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,
_("-type %c is not supported because Solaris doors "
"are not supported on the platform find was compiled on."),
(*typeletter));
#endif
break;
default: /* None of the above ... nuke 'em. */
error (EXIT_FAILURE, 0,
_("Unknown argument to -type: %c"), (*typeletter));