about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBart Schaefer <schaefer@zsh.org>2023-11-23 13:23:55 -0800
committerBart Schaefer <schaefer@zsh.org>2023-11-23 13:23:55 -0800
commitfbec213cc5ab0d0316c98bd9ddb883bae3bbdbc5 (patch)
treee6ea125a6b117e989b7b990b9f8d96ad2b2013b5
parent7a84713bb7a1527d4ef9bfa8c745d1bfa7da9d59 (diff)
downloadzsh-fbec213cc5ab0d0316c98bd9ddb883bae3bbdbc5.tar.gz
zsh-fbec213cc5ab0d0316c98bd9ddb883bae3bbdbc5.tar.xz
zsh-fbec213cc5ab0d0316c98bd9ddb883bae3bbdbc5.zip
52325: Clarify doc for edge cases of named references and nofork substitution
Unposted whitespace change avoids a parse error in ${ ... } with comments.
-rw-r--r--ChangeLog9
-rw-r--r--Doc/Zsh/expn.yo8
-rw-r--r--Doc/Zsh/mod_ksh93.yo7
-rw-r--r--Doc/Zsh/params.yo10
-rw-r--r--Src/subst.c2
-rw-r--r--Test/D10nofork.ztst2
6 files changed, 25 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 8932d60d9..64155b175 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2023-11-23  Bart Schaefer  <schaefer@zsh.org>
+
+	* 52325: Doc/Zsh/expn.yo, Doc/Zsh/mod_ksh93.yo, Doc/Zsh/params.yo:
+	Clarify side-effects of $argv and named references to specials,
+	update ksh93 feature compatibility.
+
+	unposted: Src/subst.c, Test/D10nofork.ztst: whitespace tweak to
+	avoid unexpected parse error when comments are used in ${ ... }
+
 2023-11-22  Oliver Kiddle  <opk@zsh.org>
 
 	* unposted: Completion/Unix/Command/_ri: fix missing closing brace
diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo
index 837a85db6..e5506d469 100644
--- a/Doc/Zsh/expn.yo
+++ b/Doc/Zsh/expn.yo
@@ -1600,6 +1600,10 @@ example(tt(before local: OUTER)
 tt(by reference: OUTER)
 tt(after func: RESULT))
 
+Note, however, that named references to em(special) parameters acquire
+the behavior of the special parameter, regardless of the scope where
+the reference is declared.
+
 When var(rname) includes an array subscript, the subscript expression
 is interpreted at the time tt(${)var(pname)tt(}) is expanded.  Any
 form of subscript is allowed, including those that select individual
@@ -1929,7 +1933,9 @@ Note that because the `tt(${|)...tt(})' and `tt(${ )...tt( })' forms
 must be parsed at once as both string tokens and commands, all other
 braces (`tt({)' or `tt(})') within the command either must be quoted,
 or must appear in syntactically valid pairs, such as around complex
-commands, function bodies, or parameter references.
+commands, function bodies, or parameter references.  Furthermore,
+comments are always recognized, even when tt(NO_INTERACTIVE_COMMENTS)
+is in effect.
 
 texinode(Arithmetic Expansion)(Brace Expansion)(Command Substitution)(Expansion)
 sect(Arithmetic Expansion)
diff --git a/Doc/Zsh/mod_ksh93.yo b/Doc/Zsh/mod_ksh93.yo
index 99dab385f..9cd708d10 100644
--- a/Doc/Zsh/mod_ksh93.yo
+++ b/Doc/Zsh/mod_ksh93.yo
@@ -186,13 +186,6 @@ parameter var(name) would be unset.  The function must explicitly
 
 em(THIS FEATURE IS NOT YET IMPLEMENTED.)
 )
-item(tt(${ )var(list)tt(;}))(
-Note the space after the opening brace (tt({)). This executes var(list)
-in the current shell and substitutes its standard output in the manner
-of `tt($LPAR())var(list)tt(RPAR())' but without forking.
-
-em(THIS FEATURE IS NOT YET IMPLEMENTED.)
-)
 item(tt(typeset -C )var(name)[tt(=)var(values)tt( ...)])(
 Creates a em(compound variable).
 
diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo
index 5653b3bc9..68df4a16f 100644
--- a/Doc/Zsh/params.yo
+++ b/Doc/Zsh/params.yo
@@ -748,9 +748,13 @@ vindex(argv)
 item(tt(argv) <S> <Z>)(
 Same as tt(*).  Assigning to tt(argv) changes the local positional
 parameters, but tt(argv) is em(not) itself a local parameter.
-Deleting tt(argv) with tt(unset) in any function deletes it everywhere,
-although only the innermost positional parameter array is deleted (so
-tt(*) and tt(@) in other scopes are not affected).
+Deleting tt(argv) with tt(unset) in any function deletes it everywhere.
+This can be avoided by declaring `tt(local +h argv)' before unsetting.
+Even when not so declared, only the innermost positional parameter
+array is deleted (so tt(*) and tt(@) in other scopes are not affected).
+
+A named reference to tt(argv) em(does not) permit a called function to
+access the positional parameters of its caller.
 )
 vindex(@)
 item(tt(@) <S>)(
diff --git a/Src/subst.c b/Src/subst.c
index 4ef1d1269..3a1187350 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -1956,7 +1956,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags,
 		     * Then fall through to the regular handling of $REPLY
 		     * to manage word splitting, expansion flags, etc.
 		     */
-		    char *outfmt = ">| %s { %s ;}";	/* 13 */
+		    char *outfmt = ">| %s {\n%s\n;}";	/* 13 */
 		    if ((rplytmp = gettempname(NULL, 1))) {
 			/* Prevent shenanigans with $TMPPREFIX */
 			char *tmpfile = quotestring(rplytmp, QT_BACKSLASH);
diff --git a/Test/D10nofork.ztst b/Test/D10nofork.ztst
index 024b8ffcc..d6a5588df 100644
--- a/Test/D10nofork.ztst
+++ b/Test/D10nofork.ztst
@@ -422,7 +422,7 @@ F:must do this before evaluating the next test block
 
   purr ${ { echo nested } } DONE
 1:ignored braces, part 4
-?(eval):1: parse error near `}'
+?(eval):3: parse error near `}'
 
   # "break" blocks function calls in outer loop
   # Could use print, but that might get fixed