Module Name: src
Committed By: bouyer
Date: Wed Jan 27 21:01:58 UTC 2010
Modified Files:
src/bin/sh [netbsd-4]: cd.c sh.1
Log Message:
Pull up following revision(s) (requested by dholland in ticket #1380):
bin/sh/cd.c: revision 1.40
bin/sh/sh.1: revision 1.95
bin/sh/sh.1: revision 1.97
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...
Bump date for cd -P support.
To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.39.4.1 src/bin/sh/cd.c
cvs rdiff -u -r1.85.2.1 -r1.85.2.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.4.1
--- src/bin/sh/cd.c:1.39 Thu May 4 11:16:53 2006
+++ src/bin/sh/cd.c Wed Jan 27 21:01:58 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.4.1 2010/01/27 21:01:58 bouyer 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.4.1 2010/01/27 21:01:58 bouyer 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.85.2.1 src/bin/sh/sh.1:1.85.2.2
--- src/bin/sh/sh.1:1.85.2.1 Mon Apr 16 19:33:51 2007
+++ src/bin/sh/sh.1 Wed Jan 27 21:01:58 2010
@@ -1,4 +1,4 @@
-.\" $NetBSD: sh.1,v 1.85.2.1 2007/04/16 19:33:51 bouyer Exp $
+.\" $NetBSD: sh.1,v 1.85.2.2 2010/01/27 21:01:58 bouyer Exp $
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -31,7 +31,7 @@
.\"
.\" @(#)sh.1 8.6 (Berkeley) 5/4/95
.\"
-.Dd March 25, 2007
+.Dd January 1, 2010
.Os
.Dt SH 1
.Sh NAME
@@ -1219,7 +1219,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
@@ -1245,6 +1245,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
@@ -1532,11 +1547,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,