Module Name:    src
Committed By:   uebayasi
Date:           Fri Jun 10 02:19:10 UTC 2011

Modified Files:
        src/bin/sh: cd.c

Log Message:
Support $OLDPWD.  (christos@ will update the manual.)

Reviewd By:     christos


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/bin/sh/cd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/sh/cd.c
diff -u src/bin/sh/cd.c:1.41 src/bin/sh/cd.c:1.42
--- src/bin/sh/cd.c:1.41	Thu Feb 17 15:13:49 2011
+++ src/bin/sh/cd.c	Fri Jun 10 02:19:10 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd.c,v 1.41 2011/02/17 15:13:49 pooka Exp $	*/
+/*	$NetBSD: cd.c,v 1.42 2011/06/10 02:19:10 uebayasi 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.41 2011/02/17 15:13:49 pooka Exp $");
+__RCSID("$NetBSD: cd.c,v 1.42 2011/06/10 02:19:10 uebayasi Exp $");
 #endif
 #endif /* not lint */
 
@@ -264,9 +264,10 @@
 		curdir = NULL;
 		getpwd(1);
 		INTON;
-		if (curdir)
+		if (curdir) {
+			setvar("OLDPWD", prevdir, VEXPORT);
 			setvar("PWD", curdir, VEXPORT);
-		else
+		} else
 			unsetvar("PWD", 0);
 		return;
 	}
@@ -297,6 +298,7 @@
 		ckfree(prevdir);
 	prevdir = curdir;
 	curdir = savestr(stackblock());
+	setvar("OLDPWD", prevdir, VEXPORT);
 	setvar("PWD", curdir, VEXPORT);
 	INTON;
 }
@@ -325,6 +327,7 @@
 	else
 		find_curdir(0);
 
+	setvar("OLDPWD", prevdir, VEXPORT);
 	setvar("PWD", curdir, VEXPORT);
 	out1str(curdir);
 	out1c('\n');

Reply via email to