Remove double square bracket. [[ is a bash or ksh built-in, and cannot be used in a #!/bin/sh script.

Submitted by Robert Langhammer on July 25, 2018, 2:45 p.m.

Details

Message ID 20180725144554.13353-1-rlanghammer@web.de
State Accepted
Headers show

Commit Message

Robert Langhammer July 25, 2018, 2:45 p.m.
Signed-off-by: Robert Langhammer <rlanghammer@web.de>
---
 src/packages/fff/fff-network/files/usr/sbin/configurenetwork | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
index 90024b3..0e038a4 100755
--- a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
+++ b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
@@ -119,7 +119,7 @@  if ! uci -q get network.$SWITCHDEV > /dev/null || [ "$FORCEPARSE" = '1' ] ; then
     uci set network.${SWITCHDEV}_1.vlan=1
     uci set network.${SWITCHDEV}_1.ports="$CLIENT_PORTS"
 
-    if [[ "$WANDEV" = "$SWITCHDEV" ]] || ! [[ -z "$WAN_PORTS" ]]; then
+    if [ "$WANDEV" = "$SWITCHDEV" ] || ! [ -z "$WAN_PORTS" ]; then
         uci set network.${SWITCHDEV}_2=switch_vlan
         uci set network.${SWITCHDEV}_2.device=$SWITCHHW
         uci set network.${SWITCHDEV}_2.vlan=2
@@ -139,7 +139,7 @@  if ! uci -q get network.$SWITCHDEV > /dev/null || [ "$FORCEPARSE" = '1' ] ; then
 
     uci set network.ethmesh.ifname="$SWITCHDEV.3"
 
-    if [[ "$WANDEV" = "$SWITCHDEV" ]]; then
+    if [ "$WANDEV" = "$SWITCHDEV" ]; then
         uci set network.wan.ifname=$WANDEV.2
     else
         uci set network.wan.ifname=$WANDEV
@@ -175,7 +175,7 @@  fi
 
 /etc/init.d/network restart
 
-if [[ -n "$ETHMESHMAC" ]]; then
+if [ -n "$ETHMESHMAC" ]; then
     if uci get network.ethmesh.macaddr
     then
         echo "MAC for ethmesh is set already"
@@ -193,7 +193,7 @@  if [[ -n "$ETHMESHMAC" ]]; then
     fi
 fi
 
-if [[ -n "$ROUTERMAC" ]]; then
+if [ -n "$ROUTERMAC" ]; then
     if uci get network.mesh.macaddr
     then
         echo "MAC for mesh is set already"
@@ -211,7 +211,7 @@  if [[ -n "$ROUTERMAC" ]]; then
     fi
 fi
 
-if [[ -n "$ETH0MAC" ]]; then
+if [ -n "$ETH0MAC" ]; then
         echo "Fixing MAC on eth0"
         sleep 10
         NEW_MACADDR=$(cat "/sys/class/net/${ETH0MAC}/address")

Comments

Tim Niemeyer July 25, 2018, 9:07 p.m.
Hi

Ja, das stimmt.

Wir verwendet ash (busybox) und die kann mehr als die POSIX sh.
Insofern funktioniert das. Korrekterweise müsste man dann aber eine
andere Shell (ash) ansprechen und nicht die sh.

Reviewed-by: Tim Niemeyer <tim@tn-x.org>

Tim

PS: Da sind überall noch mehr solche Sachen, die man auch mit dem
shellchecker findet.


Am Mittwoch, den 25.07.2018, 16:45 +0200 schrieb Robert Langhammer:
> Signed-off-by: Robert Langhammer <rlanghammer@web.de>
> ---
>  src/packages/fff/fff-network/files/usr/sbin/configurenetwork | 10
> +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/src/packages/fff/fff-
> network/files/usr/sbin/configurenetwork b/src/packages/fff/fff-
> network/files/usr/sbin/configurenetwork
> index 90024b3..0e038a4 100755
> --- a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
> +++ b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
> @@ -119,7 +119,7 @@ if ! uci -q get network.$SWITCHDEV > /dev/null ||
> [ "$FORCEPARSE" = '1' ] ; then
>      uci set network.${SWITCHDEV}_1.vlan=1
>      uci set network.${SWITCHDEV}_1.ports="$CLIENT_PORTS"
>  
> -    if [[ "$WANDEV" = "$SWITCHDEV" ]] || ! [[ -z "$WAN_PORTS" ]];
> then
> +    if [ "$WANDEV" = "$SWITCHDEV" ] || ! [ -z "$WAN_PORTS" ]; then
>          uci set network.${SWITCHDEV}_2=switch_vlan
>          uci set network.${SWITCHDEV}_2.device=$SWITCHHW
>          uci set network.${SWITCHDEV}_2.vlan=2
> @@ -139,7 +139,7 @@ if ! uci -q get network.$SWITCHDEV > /dev/null ||
> [ "$FORCEPARSE" = '1' ] ; then
>  
>      uci set network.ethmesh.ifname="$SWITCHDEV.3"
>  
> -    if [[ "$WANDEV" = "$SWITCHDEV" ]]; then
> +    if [ "$WANDEV" = "$SWITCHDEV" ]; then
>          uci set network.wan.ifname=$WANDEV.2
>      else
>          uci set network.wan.ifname=$WANDEV
> @@ -175,7 +175,7 @@ fi
>  
>  /etc/init.d/network restart
>  
> -if [[ -n "$ETHMESHMAC" ]]; then
> +if [ -n "$ETHMESHMAC" ]; then
>      if uci get network.ethmesh.macaddr
>      then
>          echo "MAC for ethmesh is set already"
> @@ -193,7 +193,7 @@ if [[ -n "$ETHMESHMAC" ]]; then
>      fi
>  fi
>  
> -if [[ -n "$ROUTERMAC" ]]; then
> +if [ -n "$ROUTERMAC" ]; then
>      if uci get network.mesh.macaddr
>      then
>          echo "MAC for mesh is set already"
> @@ -211,7 +211,7 @@ if [[ -n "$ROUTERMAC" ]]; then
>      fi
>  fi
>  
> -if [[ -n "$ETH0MAC" ]]; then
> +if [ -n "$ETH0MAC" ]; then
>          echo "Fixing MAC on eth0"
>          sleep 10
>          NEW_MACADDR=$(cat "/sys/class/net/${ETH0MAC}/address")
Adrian Schmutzler July 26, 2018, 7:28 p.m.
Reviewed-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>

> -----Original Message-----
> From: franken-dev [mailto:franken-dev-bounces@freifunk.net] On Behalf
> Of Robert Langhammer
> Sent: Mittwoch, 25. Juli 2018 16:46
> To: franken-dev@freifunk.net
> Subject: [PATCH] Remove double square bracket. [[ is a bash or ksh
built-in,
> and cannot be used in a #!/bin/sh script.
> 
> Signed-off-by: Robert Langhammer <rlanghammer@web.de>
> ---
>  src/packages/fff/fff-network/files/usr/sbin/configurenetwork | 10
+++++---
> --
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
> b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
> index 90024b3..0e038a4 100755
> --- a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
> +++ b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
> @@ -119,7 +119,7 @@ if ! uci -q get network.$SWITCHDEV > /dev/null || [
> "$FORCEPARSE" = '1' ] ; then
>      uci set network.${SWITCHDEV}_1.vlan=1
>      uci set network.${SWITCHDEV}_1.ports="$CLIENT_PORTS"
> 
> -    if [[ "$WANDEV" = "$SWITCHDEV" ]] || ! [[ -z "$WAN_PORTS" ]]; then
> +    if [ "$WANDEV" = "$SWITCHDEV" ] || ! [ -z "$WAN_PORTS" ]; then
>          uci set network.${SWITCHDEV}_2=switch_vlan
>          uci set network.${SWITCHDEV}_2.device=$SWITCHHW
>          uci set network.${SWITCHDEV}_2.vlan=2 @@ -139,7 +139,7 @@ if !
uci -q
> get network.$SWITCHDEV > /dev/null || [ "$FORCEPARSE" = '1' ] ; then
> 
>      uci set network.ethmesh.ifname="$SWITCHDEV.3"
> 
> -    if [[ "$WANDEV" = "$SWITCHDEV" ]]; then
> +    if [ "$WANDEV" = "$SWITCHDEV" ]; then
>          uci set network.wan.ifname=$WANDEV.2
>      else
>          uci set network.wan.ifname=$WANDEV @@ -175,7 +175,7 @@ fi
> 
>  /etc/init.d/network restart
> 
> -if [[ -n "$ETHMESHMAC" ]]; then
> +if [ -n "$ETHMESHMAC" ]; then
>      if uci get network.ethmesh.macaddr
>      then
>          echo "MAC for ethmesh is set already"
> @@ -193,7 +193,7 @@ if [[ -n "$ETHMESHMAC" ]]; then
>      fi
>  fi
> 
> -if [[ -n "$ROUTERMAC" ]]; then
> +if [ -n "$ROUTERMAC" ]; then
>      if uci get network.mesh.macaddr
>      then
>          echo "MAC for mesh is set already"
> @@ -211,7 +211,7 @@ if [[ -n "$ROUTERMAC" ]]; then
>      fi
>  fi
> 
> -if [[ -n "$ETH0MAC" ]]; then
> +if [ -n "$ETH0MAC" ]; then
>          echo "Fixing MAC on eth0"
>          sleep 10
>          NEW_MACADDR=$(cat "/sys/class/net/${ETH0MAC}/address")
> --
> 2.11.0
Tim Niemeyer July 26, 2018, 7:59 p.m.
Hi

Applied.

Tim

Am Mittwoch, den 25.07.2018, 16:45 +0200 schrieb Robert Langhammer:
> Signed-off-by: Robert Langhammer <rlanghammer@web.de>
> ---
>  src/packages/fff/fff-network/files/usr/sbin/configurenetwork | 10
> +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/src/packages/fff/fff-
> network/files/usr/sbin/configurenetwork b/src/packages/fff/fff-
> network/files/usr/sbin/configurenetwork
> index 90024b3..0e038a4 100755
> --- a/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
> +++ b/src/packages/fff/fff-network/files/usr/sbin/configurenetwork
> @@ -119,7 +119,7 @@ if ! uci -q get network.$SWITCHDEV > /dev/null ||
> [ "$FORCEPARSE" = '1' ] ; then
>      uci set network.${SWITCHDEV}_1.vlan=1
>      uci set network.${SWITCHDEV}_1.ports="$CLIENT_PORTS"
>  
> -    if [[ "$WANDEV" = "$SWITCHDEV" ]] || ! [[ -z "$WAN_PORTS" ]];
> then
> +    if [ "$WANDEV" = "$SWITCHDEV" ] || ! [ -z "$WAN_PORTS" ]; then
>          uci set network.${SWITCHDEV}_2=switch_vlan
>          uci set network.${SWITCHDEV}_2.device=$SWITCHHW
>          uci set network.${SWITCHDEV}_2.vlan=2
> @@ -139,7 +139,7 @@ if ! uci -q get network.$SWITCHDEV > /dev/null ||
> [ "$FORCEPARSE" = '1' ] ; then
>  
>      uci set network.ethmesh.ifname="$SWITCHDEV.3"
>  
> -    if [[ "$WANDEV" = "$SWITCHDEV" ]]; then
> +    if [ "$WANDEV" = "$SWITCHDEV" ]; then
>          uci set network.wan.ifname=$WANDEV.2
>      else
>          uci set network.wan.ifname=$WANDEV
> @@ -175,7 +175,7 @@ fi
>  
>  /etc/init.d/network restart
>  
> -if [[ -n "$ETHMESHMAC" ]]; then
> +if [ -n "$ETHMESHMAC" ]; then
>      if uci get network.ethmesh.macaddr
>      then
>          echo "MAC for ethmesh is set already"
> @@ -193,7 +193,7 @@ if [[ -n "$ETHMESHMAC" ]]; then
>      fi
>  fi
>  
> -if [[ -n "$ROUTERMAC" ]]; then
> +if [ -n "$ROUTERMAC" ]; then
>      if uci get network.mesh.macaddr
>      then
>          echo "MAC for mesh is set already"
> @@ -211,7 +211,7 @@ if [[ -n "$ROUTERMAC" ]]; then
>      fi
>  fi
>  
> -if [[ -n "$ETH0MAC" ]]; then
> +if [ -n "$ETH0MAC" ]; then
>          echo "Fixing MAC on eth0"
>          sleep 10
>          NEW_MACADDR=$(cat "/sys/class/net/${ETH0MAC}/address")