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
This commit is contained in:
parent
7bb561fbb9
commit
120c8e6c34
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=159632
@ -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);
|
||||
|
13
bin/sh/sh.1
13
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
|
||||
|
@ -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,
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user