summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikael Magnusson <mikachu@gmail.com>2026-06-07 08:11:15 +0200
committerMikael Magnusson <mikachu@gmail.com>2026-06-10 05:20:51 +0200
commitff742aa0adaa85ce77b019e500272237bafaafd0 (patch)
tree2ae29af77cb66562a7eb2ddd13c765f152055fd9
parent54692: untokenize string sent to matheval for (#) flag (diff)
downloadzsh-ff742aa0adaa85ce77b019e500272237bafaafd0.tar
zsh-ff742aa0adaa85ce77b019e500272237bafaafd0.tar.gz
zsh-ff742aa0adaa85ce77b019e500272237bafaafd0.tar.bz2
zsh-ff742aa0adaa85ce77b019e500272237bafaafd0.tar.lz
zsh-ff742aa0adaa85ce77b019e500272237bafaafd0.tar.xz
zsh-ff742aa0adaa85ce77b019e500272237bafaafd0.tar.zst
zsh-ff742aa0adaa85ce77b019e500272237bafaafd0.zip
54693: show ARGV0 and - precommand more clearly in xtrace output
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
-rw-r--r--ChangeLog3
-rw-r--r--Src/exec.c10
2 files changed, 9 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index d55769b3f..4a75f47b7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2026-06-10 Mikael Magnusson <mikachu@gmail.com>
+ * 54693: Src/exec.c: show ARGV0 and - precommand more clearly
+ in xtrace output
+
* 54692: Src/subst.c: untokenize string sent to matheval for
(#) flag
diff --git a/Src/exec.c b/Src/exec.c
index c1393a384..4240c1491 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);