Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: show ARGV0 and - precommand more clearly in xtrace output
- X-seq: zsh-workers 54693
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Cc: Stephane Chazelas <stephane@xxxxxxxxxxxx>
- Subject: PATCH: show ARGV0 and - precommand more clearly in xtrace output
- Date: Sun, 7 Jun 2026 08:24:04 +0200
- Archived-at: <https://zsh.org/workers/54693>
- In-reply-to: <20210523060322.4ngr2yh2atnfqesm@chazelas.org>
- List-id: <zsh-workers.zsh.org>
- References: <20210523060322.4ngr2yh2atnfqesm@chazelas.org>
Reported in 48901.
Also has a secondary effect of correcting the string sent to the
command_not_found_handler. If you don't have such a handler, then the
errors are correct before the patch as well.
command_not_found_handler() { echo -E >&2 command not found: $1 }
Before:
% ARGV0=foobar blurg
zsh:1> ARGV0=foobar foobar
command not found: foobar
% - blurg
+zsh:1> -blurg
command not found: -blurg
% ARGV0=foobar - blurg
+zsh:1> ARGV0=foobar foobar
command not found: foobar
After:
% ARGV0=foobar blurg
+zsh:1> ARGV0=foobar blurg
command not found: blurg
% - blurg
+zsh:1> - blurg
command not found: blurg
% ARGV0=foobar - blurg
+zsh:1> ARGV0=foobar - blurg
command not found: blurg
---
Src/exec.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/Src/exec.c b/Src/exec.c
index c1393a3843..4240c14910 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -753,10 +753,12 @@ execute(LinkList args, int flags, int defpath)
zsfree(s);
}
+ argv = makecline(args, flags & BINF_DASH);
+
/* If ARGV0 is in the commands environment, we use *
* that as argv[0] for this external command */
if ((z = zgetenv("ARGV0"))) {
- setdata(firstnode(args), (void *) ztrdup(z));
+ argv[0] = ztrdup(z);
/*
* Note we don't do anything with the parameter structure
* for ARGV0: that's OK since we're about to exec or exit
@@ -771,10 +773,9 @@ execute(LinkList args, int flags, int defpath)
/* Else if the pre-command `-' was given, we add `-' *
* to the front of argv[0] for this command. */
sprintf(buf2, "-%s", arg0);
- setdata(firstnode(args), (void *) ztrdup(buf2));
+ argv[0] = ztrdup(buf2);
}
- argv = makecline(args);
if (flags & BINF_CLEARENV)
newenvp = blank_env;
@@ -2098,7 +2099,7 @@ execpline2(Estate state, wordcode pcode,
/**/
static char **
-makecline(LinkList list)
+makecline(LinkList list, int dash)
{
LinkNode node;
char **argv, **ptr;
@@ -2111,6 +2112,7 @@ makecline(LinkList list)
if (!doneps4)
printprompt4();
+ if (dash) fputs("- ", xtrerr);
for (node = firstnode(list); node; incnode(node)) {
*ptr++ = (char *)getdata(node);
quotedzputs(getdata(node), xtrerr);
--
2.38.1
Messages sorted by:
Reverse Date,
Date,
Thread,
Author