Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] zshmisc(1): document implicit append of `term` when `in word` is omitted



In code such as:

> hobbes% () { for arg do print -r $arg; done; } 1 2 3
> 1
> 2
> 3

the implicit `in "$@"` added when the `in word ...` list is omitted
also implicitly appends the separator term, making the above
code valid.

This is fairly innocuous behavior and is POSIX-compliant, so document
this odd edge case rather than risk regressions attempting to change
the lexer/parser code.
---
 Doc/Zsh/grammar.yo | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Doc/Zsh/grammar.yo b/Doc/Zsh/grammar.yo
index d2c7cd29c289287066..33aa3a4c5965771971 100644
--- a/Doc/Zsh/grammar.yo
+++ b/Doc/Zsh/grammar.yo
@@ -185,11 +185,12 @@ cindex(loops, for)
 item(tt(for) var(name) ... [ tt(in) var(word) ... ] var(term) tt(do) var(list) tt(done))(
 where var(term) is at least one newline or tt(;).
 Expand the list of var(word)s, and set the parameter
 var(name) to each of them in turn, executing
 var(list) each time.  If the tt(in) var(word) is omitted,
-use the positional parameters instead of the var(word)s.
+use the positional parameters with a var(term) implicitly
+appended instead of the var(word)s.
 
 More than one parameter var(name) can appear before the list of
 var(word)s.  If var(N) var(name)s are given, then on each execution of the
 loop the next var(N) var(word)s are assigned to the corresponding
 parameters.  If there are more var(name)s than remaining var(word)s, the
-- 
Cheers,
Joey Pabalinas

Attachment: signature.asc
Description: PGP signature



Messages sorted by: Reverse Date, Date, Thread, Author