Module Name: src
Committed By: dholland
Date: Fri Jan 1 19:34:59 UTC 2010
Modified Files:
src/bin/sh: cd.c sh.1
Log Message:
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.40 src/bin/sh/cd.c
cvs rdiff -u -r1.94 -r1.95 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.40
--- src/bin/sh/cd.c:1.39 Thu May 4 11:16:53 2006
+++ src/bin/sh/cd.c Fri Jan 1 19:34:59 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: cd.c,v 1.39 2006/05/04 11:16:53 simonb Exp $ */
+/* $NetBSD: cd.c,v 1.40 2010/01/01 19:34:59 dholland 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.40 2010/01/01 19:34:59 dholland 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.94 src/bin/sh/sh.1:1.95
--- src/bin/sh/sh.1:1.94 Fri Jan 1 18:09:16 2010
+++ src/bin/sh/sh.1 Fri Jan 1 19:34:59 2010
@@ -1,4 +1,4 @@
-.\" $NetBSD: sh.1,v 1.94 2010/01/01 18:09:16 dholland Exp $
+.\" $NetBSD: sh.1,v 1.95 2010/01/01 19:34:59 dholland Exp $
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -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
@@ -1525,11 +1540,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,