base-files: functions.sh: prepend() always adds separator
authorPhilip Prindeville <philipp@redfish-solutions.com>
Mon, 1 Jan 2024 22:37:34 +0000 (15:37 -0700)
committerPhilip Prindeville <philipp@redfish-solutions.com>
Mon, 15 Jan 2024 17:41:09 +0000 (10:41 -0700)
It shouldn't gate on the value, since the value will ostensibly
always be set; instead it should depend on the variable being
prepended to being non-empty.

Fixes #14403

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
package/base-files/files/lib/functions.sh

index 851d2f1791cfabd4d556bc637fe2c9db7bac996e..d23a56e0cf0848e9f4449ff8112814c9fe7078d5 100644 (file)
@@ -45,7 +45,7 @@ prepend() {
        local value="$2"
        local sep="${3:- }"
 
-       eval "export ${NO_EXPORT:+-n} -- \"$var=\${$value:+\${$value}\$sep}\$var\""
+       eval "export ${NO_EXPORT:+-n} -- \"$var=\$value\${$var:+\${sep}\${$var}}\""
 }
 
 list_contains() {