[PATCH v2] cmd: setexpr: fix no matching string in gsub return empty value

Tom Rini trini at konsulko.com
Mon Mar 4 16:28:36 CET 2024


On Thu, Feb 08, 2024 at 03:58:27PM +0100, Massimiliano Minella wrote:

> From: Massimiliano Minella <massimiliano.minella at se.com>
> 
> In gsub, when the destination string is empty, the string 't' is
> provided and the regular expression doesn't match, then the final result
> is an empty string.
> 
> Example:
> 
> => echo ${foo}
> 
> => setenv foo
> => setexpr foo gsub e a bar
> => echo ${foo}
> 
> =>
> 
> The variable ${foo} should contain "bar" and the lack of match shouldn't
> be considered an error.
> 
> This patch fixes the erroneous behavior by removing the return
> statement and breaking out of the loop in case of lack of match.
> 
> Also add a test for the no match case.
> 
> Signed-off-by: Massimiliano Minella <massimiliano.minella at se.com>

Applied to u-boot/next, 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/20240304/0d13016c/attachment.sig>


More information about the U-Boot mailing list