[OpenWrt-Devel] [PATCH v4] brcm-wl: fix bash comparison error

Bastian Bittorf bittorf at bluebottle.com
Sun Oct 19 14:21:31 EDT 2014


* Nathan Hintz <nlhintz at hotmail.com> [19.10.2014 08:49]:
> > 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
> > 
> > the real would be the fix the output of 'wlc'.
> 
> 'wlc' is not broken, a simple test case demonstrates it works as expected:
> 
> root at e3000-1:~# wlc ifname wl0 leddc
> 0x005a000a
> root at e3000-1:~# wlc ifname wl0 leddc 0xffff
> root at e3000-1:~# wlc ifname wl0 leddc
> 0xffff
> root at e3000-1:~# leddc=$(wlc ifname wl0 leddc)
> root at e3000-1:~# [ "$leddc" = "0xffff" ] && echo yes
> yes
> root at e3000-1:~# wlc ifname wl0 leddc 0x005a000a
> root at e3000-1:~# wlc ifname wl0 leddc
> 0x005a000a
> root at e3000-1:~# leddc=$(wlc ifname wl0 leddc)
> root at e3000-1:~# [ "$leddc" = "0xffff" ] && echo yes
> root at e3000-1:~#

ah - ok. sorry felix - i really was thinking that it outputs
a string '0xffff\n' (with the symbol of a newline). so your
approach is correct but without quotes, so:

[ $((leddc)) -eq $((0xffff)) ] && ...

bye, bastian - please Álvaro send a new patch
_______________________________________________
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