scripts/utils.sh: add a function for setting a variable default
authorFelix Fietkau <nbd@openwrt.org>
Tue, 29 Oct 2013 15:11:55 +0000 (16:11 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Tue, 29 Oct 2013 15:12:11 +0000 (16:12 +0100)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
scripts/utils.sh

index 01d8ad5..a5dc782 100644 (file)
@@ -13,6 +13,12 @@ add_default_handler() {
        esac
 }
 
+set_default() {
+       local __s_var="$1"
+       local __s_val="$2"
+       eval "export -- \"$__s_var=\${$__s_var:-\$__s_val}\""
+}
+
 _config_add_generic() {
        local type="$1"; shift