don't call get/set progname when we are a shell built-in.

This commit is contained in:
christos 2006-08-04 19:07:55 +00:00
parent e7be999408
commit 8c4dec8fa5
2 changed files with 11 additions and 4 deletions

View File

@ -1,9 +1,10 @@
# $NetBSD: Makefile,v 1.8 1997/07/20 22:38:09 christos Exp $
# $NetBSD: Makefile,v 1.9 2006/08/04 19:07:55 christos Exp $
# @(#)Makefile 8.1 (Berkeley) 5/31/93
PROG= test
SRCS= test.c
LINKS= ${BINDIR}/test ${BINDIR}/[
CFLAGS+=-g
MLINKS= test.1 '[.1'
.include <bsd.prog.mk>

View File

@ -1,4 +1,4 @@
/* $NetBSD: test.c,v 1.27 2006/08/04 14:38:58 christos Exp $ */
/* $NetBSD: test.c,v 1.28 2006/08/04 19:07:55 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.27 2006/08/04 14:38:58 christos Exp $");
__RCSID("$NetBSD: test.c,v 1.28 2006/08/04 19:07:55 christos Exp $");
#endif
#include <sys/stat.h>
@ -188,9 +188,15 @@ main(int argc, char *argv[])
#endif
{
int res;
const char *argv0;
#ifdef SHELL
argv0 = argv[0];
#else
setprogname(argv[0]);
if (strcmp(getprogname(), "[") == 0) {
argv0 = getprogname();
#endif
if (strcmp(argv0, "[") == 0) {
if (strcmp(argv[--argc], "]"))
error("missing ]");
argv[argc] = NULL;