diff options
author | Daniel Shahaf <d.s@daniel.shahaf.name> | 2016-01-29 09:18:34 +0000 |
---|---|---|
committer | Daniel Shahaf <d.s@daniel.shahaf.name> | 2016-01-30 07:37:46 +0000 |
commit | 3b69b121def33bb02d01ba23a7148129ab2aed46 (patch) | |
tree | 137dffdf0f0ee47c9d413010eec8b18c90ad5018 | |
parent | ca3bc0d95d7deab4f5381f12b15047de748c0814 (diff) | |
download | zsh-3b69b121def33bb02d01ba23a7148129ab2aed46.tar.gz zsh-3b69b121def33bb02d01ba23a7148129ab2aed46.tar.xz zsh-3b69b121def33bb02d01ba23a7148129ab2aed46.zip |
37831: typeset: Document exit status difference from parameter assignment statements
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | Doc/Zsh/builtins.yo | 17 |
2 files changed, 22 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog index f7f8b218e..19a4d21f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2016-01-30 Daniel Shahaf <d.s@daniel.shahaf.name> + + * 37831: Doc/Zsh/builtins.yo: typeset: Document exit status + difference from parameter assignment statements + 2016-01-30 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> * 37838: Src/Builtins/rlimits.c, Src/Builtins/sched.c, diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo index fb630a713..cdf405b13 100644 --- a/Doc/Zsh/builtins.yo +++ b/Doc/Zsh/builtins.yo @@ -1826,6 +1826,23 @@ reserved word interface for tt(typeset) may cause problems with the output of `tt(typeset -p)', which assumes the reserved word interface is available in order to restore array and associative array values. +Unlike parameter assignment statements, tt(typeset)'s exit status on an +assignment that involves a command substitution does not reflect the exit +status of the command substitution. Therefore, to test for an error in +a command substitution, separate the declaration of the parameter from its +initialization: + +example(# WRONG +typeset var1=$(exit 1) || echo "Trouble with var1" + +# RIGHT +typeset var1 && var1=$(exit 1) || echo "Trouble with var1" +) + +To initialize a parameter var(param) to a command output and mark it readonly, +use tt(typeset -r )var(param) or tt(readonly )var(param) after the parameter +assignment statement. + If the shell option tt(TYPESET_SILENT) is not set, for each remaining var(name) that refers to a parameter that is already set, the name and value of the parameter are printed in the form of an assignment. |