some shell variable handling fixes
authorFelix Fietkau <nbd@openwrt.org>
Fri, 15 Jun 2007 15:59:56 +0000 (15:59 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Fri, 15 Jun 2007 15:59:56 +0000 (15:59 +0000)
SVN-Revision: 7638

package/base-files/files/etc/functions.sh
package/base-files/files/lib/config/uci.sh

index 7ba59afbbe24121673d2156791f3122c02798632..8d1117163d35401bca4da054735e3d8cd2f1deb1 100755 (executable)
@@ -55,7 +55,7 @@ config_rename() {
        local oldvar
        local newvar
        
-       [ "$OLD" -a "$NEW" ] || return
+       [ -n "$OLD" -a -n "$NEW" ] || return
        for oldvar in `set | grep ^CONFIG_${OLD}_ | \
                sed -e 's/\(.*\)=.*$/\1/'` ; do
                newvar="CONFIG_${NEW}_${oldvar##CONFIG_${OLD}_}"
@@ -139,7 +139,7 @@ config_foreach() {
        [ -z "$CONFIG_SECTIONS" ] && return 0
        for section in ${CONFIG_SECTIONS}; do
                config_get cfgtype "$section" TYPE
-               [ -n "$type" -a "$cfgtype" != "$type" ] && continue
+               [ -n "$type" -a "x$cfgtype" != "x$type" ] && continue
                eval "$function \"\$section\""
        done
 }
@@ -186,7 +186,7 @@ strtok() { # <string> { <variable> [<separator>] ... }
                shift 2
        done
 
-       if [ $# -gt 0 -a "$val" ]; then
+       if [ $# -gt 0 -a -n "$val" ]; then
                export ${NO_EXPORT:+-n} "$1=$val"; count=$((count+1))
        fi
 
index da6ecab51cf8a0be8a78912fddb4b7564d5ac598..a5393883590661887c6fd382f18effb1ee239709 100644 (file)
@@ -90,7 +90,7 @@ uci_set() {
                        ( # spawn a subshell so you don't mess up the current environment
                                uci_load "$PACKAGE"
                                config_get OLDVAL "$CONFIG" "$OPTION"
-                               if [ "$OLDVAL" != "$VALUE" ]; then
+                               if [ "x$OLDVAL" != "x$VALUE" ]; then
                                        config_get type "$CONFIG" TYPE
                                        [ -z "$type" ]
                                fi