aboutsummaryrefslogtreecommitdiffstats
path: root/package
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2009-08-07 00:07:42 +0000
committerFelix Fietkau <nbd@openwrt.org>2009-08-07 00:07:42 +0000
commit5d42c0eb62e09e9aa6da62895876f7f548756bd6 (patch)
treeb07e4546da80b476d361a3862d759708236fc113 /package
parentbc041781a00071b84cf34e7323e8b458944ac495 (diff)
downloadupstream-5d42c0eb62e09e9aa6da62895876f7f548756bd6.tar.gz
upstream-5d42c0eb62e09e9aa6da62895876f7f548756bd6.tar.bz2
upstream-5d42c0eb62e09e9aa6da62895876f7f548756bd6.zip
base-files: allow default value for config_get
Signed-off-by: Malte S. Stretz <mss@apache.org> Signed-off-by: Felix Fietkau <nbd@openwrt.org> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@17155 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package')
-rwxr-xr-xpackage/base-files/files/etc/functions.sh15
1 files changed, 9 insertions, 6 deletions
diff --git a/package/base-files/files/etc/functions.sh b/package/base-files/files/etc/functions.sh
index 828e37e404..efa378f006 100755
--- a/package/base-files/files/etc/functions.sh
+++ b/package/base-files/files/etc/functions.sh
@@ -134,22 +134,25 @@ config_clear() {
done
}
+# config_get <variable> <section> <option> [<default>]
+# config_get <section> <option>
config_get() {
case "$3" in
- "") eval "echo \"\${CONFIG_${1}_${2}}\"";;
- *) eval "export ${NO_EXPORT:+-n} -- \"$1=\${CONFIG_${2}_${3}}\"";;
+ "") eval echo "\${CONFIG_${1}_${2}:-\${4}}";;
+ *) eval export ${NO_EXPORT:+-n} -- "${1}=\${CONFIG_${2}_${3}:-\${4}}";;
esac
}
# config_get_bool <variable> <section> <option> [<default>]
config_get_bool() {
local _tmp
- config_get "_tmp" "$2" "$3"
+ config_get _tmp "$2" "$3" "$4"
case "$_tmp" in
- 1|on|true|enabled) export ${NO_EXPORT:+-n} "$1=1";;
- 0|off|false|disabled) export ${NO_EXPORT:+-n} "$1=0";;
- *) eval "$1=$4";;
+ 1|on|true|enabled) _tmp=1;;
+ 0|off|false|disabled) _tmp=0;;
+ *) _tmp="$4";;
esac
+ export ${NO_EXPORT:+-n} "$1=$_tmp"
}
config_set() {