diff options
author | Jilles Tjoelker <jilles@FreeBSD.org> | 2009-06-23 22:53:34 +0000 |
---|---|---|
committer | Jilles Tjoelker <jilles@FreeBSD.org> | 2009-06-23 22:53:34 +0000 |
commit | 689f1cbba5e2d1e772641d8018e50439e616b36d (patch) | |
tree | 2cf0c57efdd587343b50c8f9f6389056f59789cb /bin/sh | |
parent | 50c202c592c4019c36a40d861f498c3a243946f4 (diff) | |
download | src-689f1cbba5e2d1e772641d8018e50439e616b36d.tar.gz src-689f1cbba5e2d1e772641d8018e50439e616b36d.zip |
Quote -x tracing output so it is unambiguous.
It is usually but not always suitable for re-input to the shell.
Approved by: ed (mentor) (implicit)
Notes
Notes:
svn path=/head/; revision=194786
Diffstat (limited to 'bin/sh')
-rw-r--r-- | bin/sh/eval.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/bin/sh/eval.c b/bin/sh/eval.c index c0b2096f439b..39e16602abf1 100644 --- a/bin/sh/eval.c +++ b/bin/sh/eval.c @@ -642,17 +642,32 @@ evalcommand(union node *cmd, int flags, struct backcmd *backcmd) /* Print the command if xflag is set. */ if (xflag) { char sep = 0; + const char *p; out2str(ps4val()); for (sp = varlist.list ; sp ; sp = sp->next) { if (sep != 0) outc(' ', &errout); - out2str(sp->text); + p = sp->text; + while (*p != '=' && *p != '\0') + out2c(*p++); + if (*p != '\0') { + out2c(*p++); + out2qstr(p); + } sep = ' '; } for (sp = arglist.list ; sp ; sp = sp->next) { if (sep != 0) outc(' ', &errout); - out2str(sp->text); + /* Disambiguate command looking like assignment. */ + if (sp == arglist.list && + strchr(sp->text, '=') != NULL && + strchr(sp->text, '\'') == NULL) { + out2c('\''); + out2str(sp->text); + out2c('\''); + } else + out2qstr(sp->text); sep = ' '; } outc('\n', &errout); |