[PATCH v2 1/2] cmd: exit: Fix return value propagation out of environment scripts

Tom Rini trini at konsulko.com
Thu Jan 12 16:18:48 CET 2023


On Tue, Dec 20, 2022 at 07:25:59AM +0100, Marek Vasut wrote:

> 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 <hector.palacios at digi.com>
> Signed-off-by: Marek Vasut <marex at denx.de>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20230112/3937a469/attachment.sig>


More information about the U-Boot mailing list