fix shell escaping bug in append() function
[openwrt-10.03/.git] / package / base-files / default / etc / functions.sh
index a7f7c42e22cfb3ea74a367111d4338fe3a1fa603..2ce172eb358fb2cd2e6020831075d53fea78f47f 100755 (executable)
@@ -1,5 +1,6 @@
 #!/bin/sh
 # Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2006 Fokus Fraunhofer <carsten.tittel@fokus.fraunhofer.de>
 
 alias debug=${DEBUG:-:}
 
@@ -24,7 +25,7 @@ append() {
        local var="$1"
        local value="$2"
        local sep="${3:- }"
-       eval "export ${var}=\"\${${var}:+\${${var}}${value:+$sep}}$value\""
+       eval "export ${var}=\"\${${var}:+\${${var}}${value:+$sep}}\$value\""
 }
 
 reset_cb() {
@@ -38,15 +39,17 @@ reset_cb() {
 reset_cb
 
 config () {
-       _C=$(($_C + 1))
-       name="${name:-cfg${_C}}"
-       config_cb "$1" "$2"
-       export CONFIG_SECTION="$2"
-       export CONFIG_${CONFIG_SECTION}_TYPE="$1"
+    local cfgtype="$1"
+    local name="$2"
+    _C=$(($_C + 1))
+    name="${name:-cfg${_C}}"
+    config_cb "$cfgtype" "$name"
+    export CONFIG_SECTION="$name"
+    export CONFIG_${CONFIG_SECTION}_TYPE="$cfgtype"
 }
 
 option () {
-       local varname="$1" ; shift
+       local varname="$1"; shift
        export CONFIG_${CONFIG_SECTION}_${varname}="$*"
        option_cb "$varname" "$*"
 }
@@ -88,3 +91,9 @@ config_set() {
 load_modules() {
        sed 's/^[^#]/insmod &/' $* | ash 2>&- || :
 }
+
+include() {
+       for file in $(ls $1/*.sh 2>/dev/null); do
+               . $file
+       done
+}