Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Zsh - possible bug report
- X-seq: zsh-workers 41662
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: Simon Guilliams <simon.guilliams@xxxxxxxxx>, zsh-workers@xxxxxxx
- Subject: Re: Zsh - possible bug report
- Date: Sun, 10 Sep 2017 17:50:26 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ntlworld.com; s=meg.feb2017; t=1505062226; bh=yJaGp9n6+Bgojiql/pW52kD9WEyrXnEUCJfC1TWOHjs=; h=Date:From:To:Subject:In-Reply-To:References; b=x+yxKiUPoXtFPBWVXRHkpTtrJqO+5K+6eKa/iBWaHKjvUU+d9yJINNaVHq9cnw+Z9 r3my8ajQb/T7OpRYMZxGdX2Z3xtXpqrGFjpx/125kc8jM2Q1OHrcnTcB1ao966fbpV 2Fi5Pc8GGg7cAIWQaVf8AHcCUvK+3QucoAVN+MzNY7ELaN3qspjtvCMSU8Prg7j/Z5 BUNV6tPOGPPFLVK0/gfi28JJywNkSu4pCkBotCwHqiQdm0PTSFrMcJkFgh+QO5Ihls 39SdLiHhK7yexIY/A8MHpdbiotdfZsurGu2Zk1ls7ykPDLhcGFtcOPoZfcADEDl4Vx hUsd5xpsq+6aA==
- In-reply-to: <CAPtQDzpP3pf7TkvG_fQt7SB5eHt5Wfo9COuk=2z7hRMSZ4pLHA@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAPtQDzpP3pf7TkvG_fQt7SB5eHt5Wfo9COuk=2z7hRMSZ4pLHA@mail.gmail.com>
On Sun, 10 Sep 2017 15:00:28 +0200
Simon Guilliams <simon.guilliams@xxxxxxxxx> wrote:
> Hello,
>
> I have found a behavior of zsh I cannot explain. I don't know if it is a
> bug and I hope this is not a duplicate.
>
> $ cat print-argv0.c
> > #include <stdio.h>
> > int main(int ac, char **av)
> > {
> > if (ac > 0)
> > fputs(av[0], stdout);
> > }
> > $ cc print-argv0.c
> > $ zsh -f -c "exec -a '' ./a.out | hexdump -vC"
> > 00000000 9b 9b |..|
> > 00000002
> > $ zsh -f -c "exec -a \"\" ./a.out | hexdump -vC"
> > 00000000 9c 9c |..|
> > 00000002
Bug.
Thanks for the clear demonstration.
pws
diff --git a/Src/exec.c b/Src/exec.c
index 76a6bb1..e2432fd 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -3007,6 +3007,9 @@ execcmd_exec(Estate state, Execcmd_params eparams,
}
if (exec_argv0) {
char *str, *s;
+ exec_argv0 = dupstring(exec_argv0);
+ remnulargs(exec_argv0);
+ untokenize(exec_argv0);
size_t sz = strlen(exec_argv0);
str = s = zalloc(5 + 1 + sz + 1);
strcpy(s, "ARGV0=");
diff --git a/Test/A01grammar.ztst b/Test/A01grammar.ztst
index 0302c96..5e7d6ac 100644
--- a/Test/A01grammar.ztst
+++ b/Test/A01grammar.ztst
@@ -103,6 +103,12 @@
0:`exec' with -a option, no space
>/bin/SPLOOSH
+ (exec -a foo* $ZTST_testdir/../Src/zsh -fc 'print -r -- ${(V)0}')
+ (exec -a "" $ZTST_testdir/../Src/zsh -fc 'print -r -- ${(V)0}')
+0:rationalisation of arguments to exec -a
+>foo*
+>
+
(
opts=(-a /bin/WHOOOSH)
exec $opts /bin/sh -c 'echo $0'
Messages sorted by:
Reverse Date,
Date,
Thread,
Author