summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2000-01-10 03:08:06 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2000-01-10 03:08:06 +0000
commitc28b03e6fbc0d42b08a3990959556b8707cd3bd1 (patch)
tree9086599352a06ada3ceffb6a225d4755845d9e26
parentfbc1f54e890d105ccf4ee181f9192005a51e05a3 (diff)
handle glob() return values better; netbsd
-rw-r--r--sbin/restore/interactive.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/sbin/restore/interactive.c b/sbin/restore/interactive.c
index 2f425794a2b..c9199dafae2 100644
--- a/sbin/restore/interactive.c
+++ b/sbin/restore/interactive.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: interactive.c,v 1.9 1999/02/17 00:17:33 deraadt Exp $ */
+/* $OpenBSD: interactive.c,v 1.10 2000/01/10 03:08:05 deraadt Exp $ */
/* $NetBSD: interactive.c,v 1.10 1997/03/19 08:42:52 lukem Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)interactive.c 8.3 (Berkeley) 9/13/94";
#else
-static char rcsid[] = "$OpenBSD: interactive.c,v 1.9 1999/02/17 00:17:33 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: interactive.c,v 1.10 2000/01/10 03:08:05 deraadt Exp $";
#endif
#endif /* not lint */
@@ -316,6 +316,7 @@ getcmd(curdir, cmd, name, ap)
static char input[BUFSIZ];
char output[BUFSIZ];
# define rawname input /* save space by reusing input buffer */
+ int globretval;
/*
* Check to see if still processing arguments.
@@ -374,8 +375,25 @@ getnext:
snprintf(output, sizeof(output), "%s/%s", curdir, rawname);
canon(output, name);
}
- if (glob(name, GLOB_ALTDIRFUNC | GLOB_NOESCAPE, NULL, &ap->glob) < 0)
- fprintf(stderr, "%s: out of memory\n", ap->cmd);
+ if ((globretval = glob(name, GLOB_ALTDIRFUNC | GLOB_NOESCAPE,
+ NULL, &ap->glob)) < 0) {
+ fprintf(stderr, "%s: %s: ", ap->cmd, name);
+ switch (globretval) {
+ case GLOB_NOSPACE:
+ fprintf(stderr, "out of memory\n");
+ break;
+ case GLOB_NOMATCH:
+ fprintf(stderr, "no filename match.\n");
+ break;
+ case GLOB_ABORTED:
+ fprintf(stderr, "glob() aborted.\n");
+ break;
+ default:
+ fprintf(stderr, "unknown error!\n");
+ break;
+ }
+ }
+
if (ap->glob.gl_pathc == 0)
return;
ap->freeglob = 1;