Module Name: src Committed By: snj Date: Sat Jan 30 19:24:33 UTC 2010
Modified Files: src/bin/sh [netbsd-5]: cd.c sh.1 Log Message: Pull up following revision(s) (requested by dholland in ticket #1274): bin/sh/cd.c: revision 1.40 bin/sh/sh.1: revision 1.95 Make the cd builtin accept and ignore -P, which is a kshism that has been allowed to leak into POSIX and selects the behavior cd already implements. Closes PR bin/42557 and also relevant to PR pkg/42168. I suppose this should probably be pulled up to both -4 and -5... To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.39.26.1 src/bin/sh/cd.c cvs rdiff -u -r1.87.18.1 -r1.87.18.2 src/bin/sh/sh.1 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.39 src/bin/sh/cd.c:1.39.26.1 --- src/bin/sh/cd.c:1.39 Thu May 4 11:16:53 2006 +++ src/bin/sh/cd.c Sat Jan 30 19:24:32 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: cd.c,v 1.39 2006/05/04 11:16:53 simonb Exp $ */ +/* $NetBSD: cd.c,v 1.39.26.1 2010/01/30 19:24:32 snj 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.39 2006/05/04 11:16:53 simonb Exp $"); +__RCSID("$NetBSD: cd.c,v 1.39.26.1 2010/01/30 19:24:32 snj Exp $"); #endif #endif /* not lint */ @@ -84,7 +84,8 @@ struct stat statb; int print = cdprint; /* set -cdprint to enable */ - nextopt(nullstr); + while (nextopt("P") != '\0') + ; /* * Try (quite hard) to have 'curdir' defined, nothing has set Index: src/bin/sh/sh.1 diff -u src/bin/sh/sh.1:1.87.18.1 src/bin/sh/sh.1:1.87.18.2 --- src/bin/sh/sh.1:1.87.18.1 Wed Apr 1 00:25:21 2009 +++ src/bin/sh/sh.1 Sat Jan 30 19:24:32 2010 @@ -1,4 +1,4 @@ -.\" $NetBSD: sh.1,v 1.87.18.1 2009/04/01 00:25:21 snj Exp $ +.\" $NetBSD: sh.1,v 1.87.18.2 2010/01/30 19:24:32 snj Exp $ .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" @@ -1225,7 +1225,7 @@ search for the command and print the absolute pathname of utilities, the name for built-ins or the expansion of aliases. .El -.It cd Op Ar directory Op Ar replace +.It cd Oo Fl P Oc Op Ar directory Op Ar replace Switch to the specified directory (default .Ev $HOME ) . If @@ -1251,6 +1251,21 @@ is the same as that of .Ev PATH . .Pp +The +.Fl P +option instructs the shell to update +.Ev PWD +with the specified directory and change to that directory. +This is the default. +.Pp +Some shells also support a +.Fl L +option, which instructs the shell to update +.Ev PWD +with incorrect information and to change the current directory +accordingly. +This is not supported. +.Pp In an interactive shell, the .Ic cd command will print out the name of the @@ -1538,11 +1553,9 @@ .Fl L , but note that the built-in .Ic cd -command doesn't currently support +command doesn't currently support the .Fl L -or -.Fl P -and will cache (almost) the absolute path. +option and will cache (almost) the absolute path. If .Ic cd is changed,