diff options
| author | Bart Schaefer <schaefer@zsh.org> | 2024-03-04 21:07:01 -0800 |
|---|---|---|
| committer | Bart Schaefer <schaefer@zsh.org> | 2024-03-04 21:07:01 -0800 |
| commit | 610b18875ad9f4498a57e9af6903bcac3b14ff46 (patch) | |
| tree | 44123f9fbd7650323f320cb81b4ed05448dd36d1 /Doc/Zsh/expn.yo | |
| parent | 52646: extend support for highlight groups to completion explanation strings ... (diff) | |
| download | zsh-610b18875ad9f4498a57e9af6903bcac3b14ff46.tar zsh-610b18875ad9f4498a57e9af6903bcac3b14ff46.tar.gz zsh-610b18875ad9f4498a57e9af6903bcac3b14ff46.tar.bz2 zsh-610b18875ad9f4498a57e9af6903bcac3b14ff46.tar.lz zsh-610b18875ad9f4498a57e9af6903bcac3b14ff46.tar.xz zsh-610b18875ad9f4498a57e9af6903bcac3b14ff46.tar.zst zsh-610b18875ad9f4498a57e9af6903bcac3b14ff46.zip | |
52650 plus minor fixes: add -u for named references pointing to "upper" scope
Diffstat (limited to 'Doc/Zsh/expn.yo')
| -rw-r--r-- | Doc/Zsh/expn.yo | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo index 2acfd08c9..183ca6e03 100644 --- a/Doc/Zsh/expn.yo +++ b/Doc/Zsh/expn.yo @@ -1600,6 +1600,25 @@ example(tt(before local: OUTER) tt(by reference: OUTER) tt(after func: RESULT)) +To force a named reference to refer to the outer scope, even if a local +has already been declared, add the tt(-u) option when declaring the +named reference. In this case var(rname) should already exist in the +outer scope, otherwise the behavior of assignment through var(pname) +is not defined and may change the scope of the reference or fail with +a status of 1. Example of correct usage: +ifzman() +example(tt(caller=OUTER) +tt(func LPAR()RPAR() {) +tt( print before local: $caller) +tt( local caller=INNER) +tt( print after local: $caller) +tt( typeset -n -u outer=$1) +tt( print by reference: $outer) +tt( outer=RESULT) +tt(}) +tt(func caller) +tt(print after func: $caller)) + 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. |
