[OpenWrt-Devel] [PATCH 3/4] uci: add support for speed_mask to switch LED init scripts

Jo-Philipp Wich jow at openwrt.org
Fri Feb 12 09:09:11 EST 2016


Hi.

>  		switch)
> -			local port_mask
> -			json_get_vars port_mask
> +			local port_mask speed_mask
> +			json_get_vars port_mask speed_mask
>  			uci -q batch <<-EOF
>  				set system.$cfg.port_mask='$port_mask'
>  			EOF
> +			if [ -n "$speed_mask" ] ; then
> +				uci -q batch <<-EOF
> +					set system.$cfg.speed_mask='$speed_mask'

A batch "set" operation without a value results in a no-op so you can
drop the outer [ -n "$speed_mask" ] test and move the new set into the
existing batch.

> +				EOF
> +			fi

[...]

> @@ -419,6 +420,7 @@ ucidef_set_led_switch() {
>  	json_add_string sysfs "$sysfs"
>  	json_add_string trigger "$trigger"
>  	json_add_string port_mask "$port_mask"
> +	[ -n "$speed_mask" ] && json_add_string speed_mask "$speed_mask"

Same here, empty values do not result in a new key within the json
object so the [ -n "$speed_mask" ] test is superfluous, just drop it.

>  	json_select ..
>  
>  	json_select ..
> 


~ Jow
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list