PR/31548: Alexander Rigbo: $PWD not set when shell starts up, before pwd

or cd get executed.
This commit is contained in:
christos 2005-10-10 21:14:42 +00:00
parent 22239aa432
commit 8d6ffce2ad
3 changed files with 13 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cd.c,v 1.36 2005/08/20 21:07:42 dsl Exp $ */
/* $NetBSD: cd.c,v 1.37 2005/10/10 21:14:42 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)cd.c 8.2 (Berkeley) 5/4/95";
#else
__RCSID("$NetBSD: cd.c,v 1.36 2005/08/20 21:07:42 dsl Exp $");
__RCSID("$NetBSD: cd.c,v 1.37 2005/10/10 21:14:42 christos Exp $");
#endif
#endif /* not lint */
@ -331,6 +331,12 @@ pwdcmd(int argc, char **argv)
void
initpwd(void)
{
getpwd(0);
setvar("PWD", curdir, VEXPORT);
}
#define MAXPWD 256

View File

@ -1,4 +1,4 @@
/* $NetBSD: cd.h,v 1.4 2003/08/07 09:05:30 agc Exp $ */
/* $NetBSD: cd.h,v 1.5 2005/10/10 21:14:42 christos Exp $ */
/*-
* Copyright (c) 1995
@ -30,6 +30,7 @@
*
*/
void initpwd(void);
void getpwd(int);
int cdcmd(int, char **);
int pwdcmd(int, char **);

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.49 2005/07/15 17:49:43 christos Exp $ */
/* $NetBSD: main.c,v 1.50 2005/10/10 21:14:42 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 1993\n\
#if 0
static char sccsid[] = "@(#)main.c 8.7 (Berkeley) 7/19/95";
#else
__RCSID("$NetBSD: main.c,v 1.49 2005/07/15 17:49:43 christos Exp $");
__RCSID("$NetBSD: main.c,v 1.50 2005/10/10 21:14:42 christos Exp $");
#endif
#endif /* not lint */
@ -174,6 +174,7 @@ main(int argc, char **argv)
rootpid = getpid();
rootshell = 1;
init();
initpwd();
setstackmark(&smark);
procargs(argc, argv);
if (argv[0] && argv[0][0] == '-') {