From 43d6a146780d20450b3264783f6ddfba83217282 Mon Sep 17 00:00:00 2001 From: tjr Date: Thu, 25 Jul 2002 10:57:39 +0000 Subject: 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 --- bin/sh/cd.c | 4 ++-- bin/sh/options.h | 4 +++- bin/sh/sh.1 | 13 ++++++++++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/bin/sh/cd.c b/bin/sh/cd.c index cf46a02..aa1fd5a 100644 --- a/bin/sh/cd.c +++ b/bin/sh/cd.c @@ -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': diff --git a/bin/sh/options.h b/bin/sh/options.h index 016a936..5aec64e 100644 --- a/bin/sh/options.h +++ b/bin/sh/options.h @@ -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]; diff --git a/bin/sh/sh.1 b/bin/sh/sh.1 index 38410d0..0bfd9b6 100644 --- a/bin/sh/sh.1 +++ b/bin/sh/sh.1 @@ -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 -- cgit v1.1