Add a -P/-o physical option which behaves similarly to bash/ksh's options

by the same name. This option makes the cd and pwd builtins behave physically
(as opposed to logically) by default.

Submitted by:	fanf
This commit is contained in:
Tim J. Robbins 2002-07-25 10:57:39 +00:00
parent 050f7913c9
commit 7e1975c2b2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=100664
3 changed files with 17 additions and 4 deletions

View File

@ -88,7 +88,7 @@ cdcmd(int argc, char **argv)
int ch, phys, print = 0;
optreset = 1; optind = 1; opterr = 0; /* initialize getopt */
phys = 0;
phys = Pflag;
while ((ch = getopt(argc, argv, "LP")) != -1) {
switch (ch) {
case 'L':
@ -324,7 +324,7 @@ pwdcmd(int argc, char **argv)
int ch, phys;
optreset = 1; optind = 1; opterr = 0; /* initialize getopt */
phys = 0;
phys = Pflag;
while ((ch = getopt(argc, argv, "LP")) != -1) {
switch (ch) {
case 'L':

View File

@ -65,8 +65,9 @@ struct shparam {
#define uflag optlist[14].val
#define privileged optlist[15].val
#define Tflag optlist[16].val
#define Pflag optlist[17].val
#define NOPTS 17
#define NOPTS 18
struct optent {
const char *name;
@ -93,6 +94,7 @@ struct optent optlist[NOPTS] = {
{ "nounset", 'u', 0 },
{ "privileged", 'p', 0 },
{ "trapsasync", 'T', 0 },
{ "physical", 'P', 0 },
};
#else
extern struct optent optlist[NOPTS];

View File

@ -43,7 +43,7 @@
.Nd command interpreter (shell)
.Sh SYNOPSIS
.Nm
.Op Fl /+abCEefIimnpsTuVvx
.Op Fl /+abCEefIimnPpsTuVvx
.Op Fl /+o Ar longname
.Op Fl c Ar string
.Op Ar arg ...
@ -225,6 +225,17 @@ Turn on job control (set automatically when interactive).
If not interactive, read commands but do not
execute them. This is useful for checking the
syntax of shell scripts.
.It Fl P Li physical
Change the default for the
.Ic cd
and
.Ic pwd
commands from
.Fl L
(logical directory layout)
to
.Fl P
(physical directory layout).
.It Fl p Li privileged
Turn on privileged mode. This mode is enabled on startup
if either the effective user or group id is not equal to the