diff options
author | Jacek Masiulaniec <jacekm@cvs.openbsd.org> | 2011-04-21 01:14:22 +0000 |
---|---|---|
committer | Jacek Masiulaniec <jacekm@cvs.openbsd.org> | 2011-04-21 01:14:22 +0000 |
commit | 07f3d2f37336ab69e771c0f554497ae688a243c2 (patch) | |
tree | b01629dc5b74b1d2ab6566398b363af9e9b656c7 /usr.bin | |
parent | e1c4c272498607eec76f32d3a9e0a080ecb2ea95 (diff) |
find: return exit code 1 if any path could not be traversed
matches posix and the manual, ok millert
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/find/extern.h | 4 | ||||
-rw-r--r-- | usr.bin/find/find.c | 10 | ||||
-rw-r--r-- | usr.bin/find/main.c | 5 |
3 files changed, 12 insertions, 7 deletions
diff --git a/usr.bin/find/extern.h b/usr.bin/find/extern.h index a28eed963a4..737436b5932 100644 --- a/usr.bin/find/extern.h +++ b/usr.bin/find/extern.h @@ -1,4 +1,4 @@ -/* * $OpenBSD: extern.h,v 1.15 2004/09/15 18:43:45 deraadt Exp $*/ +/* * $OpenBSD: extern.h,v 1.16 2011/04/21 01:14:21 jacekm Exp $*/ /*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. @@ -35,7 +35,7 @@ void brace_subst(char *, char **, char *, int); void *emalloc(unsigned int); PLAN *find_create(char ***); -void find_execute(PLAN *, char **); +int find_execute(PLAN *, char **); PLAN *find_formplan(char **); PLAN *not_squish(PLAN *); OPTION *option(char *); diff --git a/usr.bin/find/find.c b/usr.bin/find/find.c index edfd7a4a52b..09345aeae7c 100644 --- a/usr.bin/find/find.c +++ b/usr.bin/find/find.c @@ -1,4 +1,4 @@ -/* $OpenBSD: find.c,v 1.14 2009/10/27 23:59:38 deraadt Exp $ */ +/* $OpenBSD: find.c,v 1.15 2011/04/21 01:14:21 jacekm Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -143,12 +143,15 @@ FTS *tree; /* pointer to top of FTS hierarchy */ FTSENT *entry; /* shared with SIGINFO handler */ -void +int find_execute(PLAN *plan, /* search plan */ char **paths) /* array of pathnames to traverse */ { sigset_t fullset, oset; + int rval; PLAN *p; + + rval = 0; if (!(tree = fts_open(paths, ftsoptions, NULL))) err(1, "fts_open"); @@ -178,12 +181,14 @@ find_execute(PLAN *plan, /* search plan */ case FTS_NS: (void)fflush(stdout); warn("%s", entry->fts_path); + rval = 1; continue; } #define BADCH " \t\n\\'\"" if (isxargs && strpbrk(entry->fts_path, BADCH)) { (void)fflush(stdout); warnx("%s: illegal path", entry->fts_path); + rval = 1; continue; } @@ -196,4 +201,5 @@ find_execute(PLAN *plan, /* search plan */ ; } (void)fts_close(tree); + return (rval); } diff --git a/usr.bin/find/main.c b/usr.bin/find/main.c index 9bc52b4e3f7..d509e8c70f9 100644 --- a/usr.bin/find/main.c +++ b/usr.bin/find/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.26 2009/12/20 16:15:26 schwarze Exp $ */ +/* $OpenBSD: main.c,v 1.27 2011/04/21 01:14:21 jacekm Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -126,8 +126,7 @@ main(int argc, char *argv[]) dotfd = open(".", O_RDONLY, 0); - find_execute(find_formplan(argv), paths); - exit(0); + exit(find_execute(find_formplan(argv), paths)); } static void |