Skip to content
Commit 4c736306 authored by Massimiliano Minella's avatar Massimiliano Minella Committed by Tom Rini
Browse files

cmd: setexpr: fix no matching string in gsub return empty value



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: default avatarMassimiliano Minella <massimiliano.minella@se.com>
parent fd50ae3f
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment