From: Stephane Chazelas <stephane.chazelas@gmail.com>
To: dash@vger.kernel.org
Subject: command substitutions in $PS4
Date: Mon, 17 Nov 2014 21:49:32 +0000 [thread overview]
Message-ID: <20141117214931.GA4601@chaz.gmail.com> (raw)
Hello.
[tested on current git head
f6d4def4e27b13fab174e948b94cd10550d3e10e]
Command substitution doesn't seem to work in $PS4 (used for
xtrace prompt):
$ PS4='$(date +%T)> ' dash -xc :
dash: 1: Syntax error: end of file unexpected (expecting ")")
And with the old syntax:
$ PS4='`date +%T`> ' dash -xc :
> :
And with more than one command:
$ PS4='`date +%T`> ' dash -xc ':;:'
> :
dash doesn't return and seems to go in a forking loop,
presumably because the `date` there triggers another PS4
expansion and so on recursively
If I prevent the recursion with:
--- a/src/eval.c
+++ b/src/eval.c
@@ -776,7 +776,15 @@ evalcommand(union node *cmd, int flags)
int sep;
out = &preverrout;
+
+ /*
+ * reset xflag temporarily for command substitutions performed
+ * upon $PS4 expansion
+ */
+ xflag = 0;
outstr(expandstr(ps4val()), out);
+ xflag = 1;
+
sep = 0;
sep = eprintlist(out, varlist.list, sep);
eprintlist(out, arglist.list, sep);
$ PS4='`date +%T`> ' ./src/dash -xc ':;sleep 1; date'
> :
21:43:47> sleep 1
21:43:48> date
Mon Nov 17 21:43:48 GMT 2014
The command substitution still fails upon the first expansion
only. I quickly gave up trying to find out why as I found the
code there hard to follow.
--
Stephane
next reply other threads:[~2014-11-17 21:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-17 21:49 Stephane Chazelas [this message]
2014-11-30 20:42 ` command substitutions in $PS4 Jilles Tjoelker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20141117214931.GA4601@chaz.gmail.com \
--to=stephane.chazelas@gmail.com \
--cc=dash@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).