diff options
| author | Marek Vasut <[email protected]> | 2022-12-20 07:25:59 +0100 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2023-01-11 15:02:24 -0500 |
| commit | 721307eba0e7d94241698936c58352ee3c6da748 (patch) | |
| tree | 7252c2fc1aad94b0c013ac8e092d40dac2093623 /doc/usage/cmd | |
| parent | f3d914cfdd5ac611d99f04096497f4cd13dd6aaa (diff) | |
cmd: exit: Fix return value propagation out of environment scripts
Make sure the 'exit' command as well as 'exit $val' command exits
from environment scripts immediately and propagates return value
out of those scripts fully. That means the following behavior is
expected:
"
=> setenv foo 'echo bar ; exit 1' ; run foo ; echo $?
bar
1
=> setenv foo 'echo bar ; exit 0' ; run foo ; echo $?
bar
0
=> setenv foo 'echo bar ; exit -2' ; run foo ; echo $?
bar
0
"
As well as the followin behavior:
"
=> setenv foo 'echo bar ; exit 3 ; echo fail'; run foo; echo $?
bar
3
=> setenv foo 'echo bar ; exit 1 ; echo fail'; run foo; echo $?
bar
1
=> setenv foo 'echo bar ; exit 0 ; echo fail'; run foo; echo $?
bar
0
=> setenv foo 'echo bar ; exit -1 ; echo fail'; run foo; echo $?
bar
0
=> setenv foo 'echo bar ; exit -2 ; echo fail'; run foo; echo $?
bar
0
=> setenv foo 'echo bar ; exit ; echo fail'; run foo; echo $?
bar
0
"
Fixes: 8c4e3b79bd0 ("cmd: exit: Fix return value")
Reviewed-by: Hector Palacios <[email protected]>
Signed-off-by: Marek Vasut <[email protected]>
Diffstat (limited to 'doc/usage/cmd')
| -rw-r--r-- | doc/usage/cmd/exit.rst | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/doc/usage/cmd/exit.rst b/doc/usage/cmd/exit.rst index 769223c4775..3edb12809ce 100644 --- a/doc/usage/cmd/exit.rst +++ b/doc/usage/cmd/exit.rst @@ -37,4 +37,6 @@ executed. Return value ------------ -$? is always set to 0 (true). +$? is default set to 0 (true). In case zero or positive integer parameter +is passed to the command, the return value is the parameter value. In case +negative integer parameter is passed to the command, the return value is 0. |
