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...
This commit is contained in:
dholland 2010-01-01 19:34:59 +00:00
parent 87e87a1f8c
commit cd0a6973f8
2 changed files with 23 additions and 9 deletions

View File

@ -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 @@ cdcmd(int argc, char **argv)
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

View File

@ -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 @@ Do not execute the command but
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 @@ The format of
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 @@ The default is
.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,