use getprogname() instead of argv[0], because some programs that execv, pass

the full path in argv[0] instead of just the basename. In reality, those
programs should be fixed (hello gdb for example).
This commit is contained in:
christos 2006-08-04 14:38:58 +00:00
parent e99f3cca81
commit c338573fdf
1 changed files with 3 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: test.c,v 1.26 2005/02/10 06:56:55 simonb Exp $ */
/* $NetBSD: test.c,v 1.27 2006/08/04 14:38:58 christos Exp $ */
/*
* test(1); version 7-like -- author Erik Baalbergen
@ -12,7 +12,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: test.c,v 1.26 2005/02/10 06:56:55 simonb Exp $");
__RCSID("$NetBSD: test.c,v 1.27 2006/08/04 14:38:58 christos Exp $");
#endif
#include <sys/stat.h>
@ -190,7 +190,7 @@ main(int argc, char *argv[])
int res;
setprogname(argv[0]);
if (strcmp(argv[0], "[") == 0) {
if (strcmp(getprogname(), "[") == 0) {
if (strcmp(argv[--argc], "]"))
error("missing ]");
argv[argc] = NULL;