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 01d8ad5989f5092346823b4e277fab360b1c706d..a5dc782bfd4363340a5419341a7f27e2cbf7d3eb 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