mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-12 06:12:58 +00:00
721307eba0
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: 8c4e3b79bd
("cmd: exit: Fix return value")
Reviewed-by: Hector Palacios <hector.palacios@digi.com>
Signed-off-by: Marek Vasut <marex@denx.de>
42 lines
869 B
ReStructuredText
42 lines
869 B
ReStructuredText
exit command
|
|
============
|
|
|
|
Synopsis
|
|
--------
|
|
|
|
::
|
|
|
|
exit
|
|
|
|
Description
|
|
-----------
|
|
|
|
The exit command terminates a script started via the run or source command.
|
|
If scripts are nested, only the innermost script is left.
|
|
|
|
::
|
|
|
|
=> setenv inner 'echo entry inner; exit; echo inner done'
|
|
=> setenv outer 'echo entry outer; run inner; echo outer done'
|
|
=> run outer
|
|
entry outer
|
|
entry inner
|
|
outer done
|
|
=>
|
|
|
|
When executed outside a script a warning is written. Following commands are not
|
|
executed.
|
|
|
|
::
|
|
|
|
=> echo first; exit; echo last
|
|
first
|
|
exit not allowed from main input shell.
|
|
=>
|
|
|
|
Return value
|
|
------------
|
|
|
|
$? 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.
|