summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorstefanf <stefanf@FreeBSD.org>2006-06-15 07:00:49 +0000
committerstefanf <stefanf@FreeBSD.org>2006-06-15 07:00:49 +0000
commit40616c7bb389aaa1e23907cad897503212b8e51e (patch)
treeffddd6afca1624ba622d55a632b321308ad597fc /bin
parent1689a257a3225150b95ea8241663b4784ac60e9f (diff)
downloadFreeBSD-src-40616c7bb389aaa1e23907cad897503212b8e51e.zip
FreeBSD-src-40616c7bb389aaa1e23907cad897503212b8e51e.tar.gz
Implement the PS4 variable which is defined by the POSIX User Portability
Utilities option. Its value is printed at the beginning of the line if tracing (-x) is active. PS4 defaults to the string "+ " which is compatible with the old behaviour to always print "+ ". We still need to expand variables in PS1, PS2 and PS4. PR: 46441 (part of) Submitted by: schweikh Obtained from: NetBSD
Diffstat (limited to 'bin')
-rw-r--r--bin/sh/eval.c11
-rw-r--r--bin/sh/sh.113
-rw-r--r--bin/sh/var.c3
-rw-r--r--bin/sh/var.h2
4 files changed, 23 insertions, 6 deletions
diff --git a/bin/sh/eval.c b/bin/sh/eval.c
index fa2fe59..dc0236d 100644
--- a/bin/sh/eval.c
+++ b/bin/sh/eval.c
@@ -643,14 +643,19 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd)
/* Print the command if xflag is set. */
if (xflag) {
- outc('+', &errout);
+ char sep = 0;
+ out2str(ps4val());
for (sp = varlist.list ; sp ; sp = sp->next) {
- outc(' ', &errout);
+ if (sep != 0)
+ outc(' ', &errout);
out2str(sp->text);
+ sep = ' ';
}
for (sp = arglist.list ; sp ; sp = sp->next) {
- outc(' ', &errout);
+ if (sep != 0)
+ outc(' ', &errout);
out2str(sp->text);
+ sep = ' ';
}
outc('\n', &errout);
flushout(&errout);
diff --git a/bin/sh/sh.1 b/bin/sh/sh.1
index 3c2fa9c..438fc24 100644
--- a/bin/sh/sh.1
+++ b/bin/sh/sh.1
@@ -32,7 +32,7 @@
.\" from: @(#)sh.1 8.6 (Berkeley) 5/4/95
.\" $FreeBSD$
.\"
-.Dd December 8, 2005
+.Dd June 15, 2006
.Dt SH 1
.Os
.Sh NAME
@@ -305,8 +305,9 @@ as it is read.
Useful for debugging.
.It Fl x Li xtrace
Write each command
-(preceded by
-.Dq Li "+ " )
+(preceded by the value of the
+.Ev PS4
+variable)
to standard error before it is executed.
Useful for debugging.
.El
@@ -2197,6 +2198,12 @@ unless you are the superuser, in which case it defaults to
.It Ev PS2
The secondary prompt string, which defaults to
.Dq Li "> " .
+.It Ev PS4
+The prefix for the trace output (if
+.Fl x
+is active).
+The default is
+.Dq Li "+ " .
.It Ev TERM
The default terminal setting for the shell.
This is inherited by children of the shell, and is used in the history
diff --git a/bin/sh/var.c b/bin/sh/var.c
index 4dc54b0..54a0a84 100644
--- a/bin/sh/var.c
+++ b/bin/sh/var.c
@@ -88,6 +88,7 @@ struct var vpath;
struct var vppid;
struct var vps1;
struct var vps2;
+struct var vps4;
struct var vvers;
STATIC struct var voptind;
@@ -111,6 +112,8 @@ STATIC const struct varinit varinit[] = {
*/
{ &vps2, VSTRFIXED|VTEXTFIXED, "PS2=> ",
NULL },
+ { &vps4, VSTRFIXED|VTEXTFIXED, "PS4=+ ",
+ NULL },
{ &voptind, VSTRFIXED|VTEXTFIXED, "OPTIND=1",
getoptsreset },
{ NULL, 0, NULL,
diff --git a/bin/sh/var.h b/bin/sh/var.h
index 4eb5dc1..c1f994b 100644
--- a/bin/sh/var.h
+++ b/bin/sh/var.h
@@ -74,6 +74,7 @@ extern struct var vpath;
extern struct var vppid;
extern struct var vps1;
extern struct var vps2;
+extern struct var vps4;
#ifndef NO_HISTORY
extern struct var vhistsize;
#endif
@@ -91,6 +92,7 @@ extern struct var vhistsize;
#define pathval() (vpath.text + 5)
#define ps1val() (vps1.text + 4)
#define ps2val() (vps2.text + 4)
+#define ps4val() (vps4.text + 4)
#define optindval() (voptind.text + 7)
#ifndef NO_HISTORY
#define histsizeval() (vhistsize.text + 9)
OpenPOWER on IntegriCloud