Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/bin/sh Make the cd builtin accept and ignore -P, which is a ...
details: https://anonhg.NetBSD.org/src/rev/4a0cb0da0ad4
branches: trunk
changeset: 750464:4a0cb0da0ad4
user: dholland <dholland%NetBSD.org@localhost>
date: Fri Jan 01 19:34:59 2010 +0000
description:
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...
diffstat:
bin/sh/cd.c | 7 ++++---
bin/sh/sh.1 | 25 +++++++++++++++++++------
2 files changed, 23 insertions(+), 9 deletions(-)
diffs (82 lines):
diff -r baebf35b8e44 -r 4a0cb0da0ad4 bin/sh/cd.c
--- a/bin/sh/cd.c Fri Jan 01 18:09:16 2010 +0000
+++ b/bin/sh/cd.c Fri Jan 01 19:34:59 2010 +0000
@@ -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
diff -r baebf35b8e44 -r 4a0cb0da0ad4 bin/sh/sh.1
--- a/bin/sh/sh.1 Fri Jan 01 18:09:16 2010 +0000
+++ b/bin/sh/sh.1 Fri Jan 01 19:34:59 2010 +0000
@@ -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,
Home |
Main Index |
Thread Index |
Old Index