[OpenWrt-Devel] [PATCH v4] brcm-wl: fix bash comparison error
Felix Fietkau
nbd at openwrt.org
Sat Oct 18 16:50:07 EDT 2014
On 2014-10-18 22:37, Bastian Bittorf wrote:
> * Nathan Hintz <nlhintz at hotmail.com> [18.10.2014 22:24]:
>> Using the "\n" is not correct. I think the real problem is that the logic is reversed (should be && instead of ||); although it might
>> be better to eliminate the conditional entirely since leddc is always commanded to "0xffff" when the interface is taken down.
>>
>> local leddc=$(wlc ifname "$device" leddc)
>> [ "$leddc" = "0xffff" ] && {
>> leddc=0x005a000a
>> }
>
> what about:
>
> case "$leddc" in
> '0xffff'*)
> leddc='0x005a000a'
> ;;
> esac
>
> IMHO the approach from felix does not work:
> root at box:~ echo $((0xffff))
> 65535
> root at box:~ echo $((0xffff\n))
> -ash: arithmetic syntax error
Your testcase is wrong: \n does not get substituted for a newline here.
If you test with a script that outputs an extra newline, using $(()) works.
- Felix
_______________________________________________
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