Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Possibly unexpected difference between builtin and reserved typeset
- X-seq: zsh-workers 39381
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh workers <zsh-workers@xxxxxxx>
- Subject: Re: Possibly unexpected difference between builtin and reserved typeset
- Date: Sun, 18 Sep 2016 13:41:57 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=3U21RiUNWglSbv+KPngqbbk9lP7+IxaAV/aJ7iUcSq8=; b=FavA6/7zeFZyOmjVHZ9G5rexZbEZtPuVWM8sWCjCS+lLeQWS+BnWoYtvc8pamflHYx qD4OGk1pC2/DPxeR4R4EVxStQoKcEZRhwvf8RyFQG0zXzoQGvHqMAnrp12OoUVpfh8xE oLMsvhtg15HjRswz0JVMb8cpw6sN7YqxT2l6Y5v84DjiLOSmcyrGElV57BurrpW4brcT xw5Wfitj9kpCz8EqT252t7zRAGp36fKyW36W6C7ItsyH9WRCKxJ1HRa9fTpmr3ZCSz8t BpKU79BOyhapmR5MOQ3SHvAo1dH6mP7gzJifIOuvUthS4kocsjtYNcGxmBkt5+r1xDFM 1g3A==
- In-reply-to: <CAHYJk3QgwoRNggM2CxVauEuB4UXeYv59AwwdAs20rNM4XryWHg@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: <CAHYJk3QgwoRNggM2CxVauEuB4UXeYv59AwwdAs20rNM4XryWHg@mail.gmail.com>
On Sep 15, 11:29am, Mikael Magnusson wrote:
} Subject: Possibly unexpected difference between builtin and reserved types
}
} % foo=bar \typeset foo; echo . $foo .
} foo=bar
} . .
} % foo=bar typeset foo; echo . $foo .
} foo=bar
} . bar .
}
} Out of the ones I tried in $reswords, typeset and friends seem to be
} the only ones that aren't a syntax error after parameter assignments,
} so I guess that might be why the code doesn't handle it?
This is related to the "x=2 | ..." problem discussed in another thread,
but easier to fix.
I think the following does the right thing WRT POSIX_BUILTINS, but if
anyone would care to devise a test case, please do.
There's one potential strange edge case. *Before* the patch below:
torch% foo=bar
torch% foo=fred \typeset foo=ding; echo . $foo .
. bar .
torch% foo=fred typeset foo=ding; echo . $foo .
. ding .
*After* the patch:
torch% foo=bar
torch% foo=fred \typeset foo=ding; echo . $foo .
. bar .
torch% foo=fred typeset foo=ding; echo . $foo .
. bar .
I believe only the before+resword case is correct, that is, all four
should end up with "ding" assigned to $foo, and if that's true, it's
going to be pretty ugly to fix -- but it's possible that both after
cases are correct.
diff --git a/Src/exec.c b/Src/exec.c
index 9a7234e..d924148 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -3543,7 +3543,7 @@ execcmd(Estate state, int input, int output, int how, int last1)
* if it's got "command" in front.
* If it's a normal command --- save.
*/
- if (is_shfunc || (hn->flags & BINF_PSPECIAL))
+ if (is_shfunc || (hn->flags & (BINF_PSPECIAL|BINF_ASSIGN)))
do_save = (orig_cflags & BINF_COMMAND);
else
do_save = 1;
@@ -3552,7 +3552,7 @@ execcmd(Estate state, int input, int output, int how, int last1)
* Save if it's got "command" in front or it's
* not a magic-equals assignment.
*/
- if ((cflags & BINF_COMMAND) || !assign)
+ if ((cflags & (BINF_COMMAND|BINF_ASSIGN)) || !assign)
do_save = 1;
}
if (do_save && varspc)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author