diff options
author | Bart Schaefer <schaefer@zsh.org> | 2024-04-01 22:35:33 -0700 |
---|---|---|
committer | Bart Schaefer <schaefer@zsh.org> | 2024-04-01 22:35:33 -0700 |
commit | 76019f71742fab725011e4fd0402e941544cf5ab (patch) | |
tree | 7da744ffd377425bd56d3307617107eec49aa6b9 /Test | |
parent | 5ba43e58c269100a6e3adcfc118ae93346ba0165 (diff) | |
download | zsh-76019f71742fab725011e4fd0402e941544cf5ab.tar.gz zsh-76019f71742fab725011e4fd0402e941544cf5ab.tar.xz zsh-76019f71742fab725011e4fd0402e941544cf5ab.zip |
52864: Change ${|var|...} to ${{var} ...}, limit local REPLY to ${|...}
Diffstat (limited to 'Test')
-rw-r--r-- | Test/D10nofork.ztst | 52 | ||||
-rw-r--r-- | Test/V10private.ztst | 8 |
2 files changed, 49 insertions, 11 deletions
diff --git a/Test/D10nofork.ztst b/Test/D10nofork.ztst index fc6b84613..5bb10266f 100644 --- a/Test/D10nofork.ztst +++ b/Test/D10nofork.ztst @@ -14,6 +14,28 @@ 0:Basic substitution and REPLY scoping >INNER OUTER + reply=(x OUTER x) + purl ${{reply} reply=(\{ INNER \})} $reply +0:Basic substitution, brace quoting, and array result +>{ +>INNER +>} +>{ +>INNER +>} + + () { + setopt localoptions ignorebraces + purl ${{reply} reply=({ INNER })} $reply + } +0:Basic substitution, ignorebraces, and array result +>{ +>INNER +>} +>{ +>INNER +>} + purr ${| REPLY=first}:${| REPLY=second}:$REPLY 0:re-scoping of REPLY in one statement >first:second:OUTER @@ -229,7 +251,7 @@ F:Why not use this error in the previous case as well? >26 unset reply - purl ${|reply| reply=(1 2 ${| REPLY=3 } 4) } + purl ${{reply} reply=(1 2 ${| REPLY=3 } 4) } typeset -p reply 0:array behavior with global assignment >1 @@ -315,7 +337,7 @@ F:status of "print" should hide return unset zz outer=GLOBAL - purr "${|zz| + purr "${{zz} local outer=LOCAL zz=NONLOCAL } $outer $?" @@ -440,7 +462,8 @@ F:must do this before evaluating the next test block 0:ignored braces, part 1 >buried} - purr "${ purr ${REPLY:-buried}}}" + # Global $REPLY still set from earlier test + purr "${ purr ${REPLY:+buried}}}" 0:ignored braces, part 2 >buried >} @@ -453,6 +476,7 @@ F:must do this before evaluating the next test block 1:ignored braces, part 4 ?(eval):3: parse error near `}' + unsetopt ignorebraces # "break" blocks function calls in outer loop # Could use print, but that might get fixed repeat 3 do purr ${ @@ -467,11 +491,25 @@ F:must do this before evaluating the next test block ?1 ?2 - print -u $ZTST_fd ${ZTST_testname}: TEST COMPLETE -0:make sure we got to the end -F:some tests might silently break the test harness + # Cannot "purr": break skips pending function calls + # Use "repeat" to avoid infinite loop on failure + repeat 3 do; echo ${|REPLY=x; break }; done + repeat 3 do; echo ${{x} x=y; break }; done + repeat 3 do; echo ${ echo z; break }; done +0:break after assignment completes the assignment +>x +>y +>z + + # Subshell because error exits + ( purr ${ echo ${unset?oops} } ) +1:error handling (without crashing) +*?*unset: oops + + purr ${ .zsh.cmdsubst=error } +1:reserved parameter name (without crashing) +*?*.zsh.cmdsubst: can't modify read-only parameter %clean unfunction purr purl - unsetopt ignorebraces diff --git a/Test/V10private.ztst b/Test/V10private.ztst index ed51316f3..26004a2dc 100644 --- a/Test/V10private.ztst +++ b/Test/V10private.ztst @@ -497,7 +497,7 @@ F:Better if caught in checkclobberparam() but exec.c doesn't know scope () { private z=outer print ${(t)z} $z - print ${| REPLY=${|z| z=nofork} } + print ${| REPLY=${{z} z=nofork} } print ${(t)z} $z } 0:nofork may write to private in calling function @@ -518,9 +518,9 @@ F:Better if caught in checkclobberparam() but exec.c doesn't know scope () { private z=outer print ${(t)z} $z - print ${|z| + print ${{z} private q - z=${|q| q=nofork} + z=${{q} q=nofork} } print ${(t)z} $z } @@ -533,7 +533,7 @@ F:Better if caught in checkclobberparam() but exec.c doesn't know scope print ${| () { REPLY="{$q}" } } - print ${|q| + print ${{q} () { q=nofork } } } |