aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2016-03-04 11:53:26 +0100
committerAleksander Morgado <aleksander@aleksander.es>2016-03-04 12:52:02 +0100
commite6ab0885eacde792eafc5a117af8a87647b7b747 (patch)
tree0b1d1fde2a07e0a00c2fadcd26cf06d15234e530 /utils
parent3465107153e373adfd4e50ac90259ed25d556bed (diff)
qmi-network: update checks of variable contents
Use -z and -n consistently.
Diffstat (limited to 'utils')
-rwxr-xr-xutils/qmi-network.in56
1 files changed, 28 insertions, 28 deletions
diff --git a/utils/qmi-network.in b/utils/qmi-network.in
index b7b22ca..52dc54c 100755
--- a/utils/qmi-network.in
+++ b/utils/qmi-network.in
@@ -116,7 +116,7 @@ while [ $# -gt 2 ]; do
esac
done
-if [ "x$PROFILE_FILE" = "x" ]; then
+if [ -z "$PROFILE_FILE" ]; then
echo "error: empty profile path given" 1>&2
print_usage
exit 255
@@ -135,17 +135,17 @@ STATE_FILE=/tmp/qmi-network-state-`basename $DEVICE`
load_profile ()
{
- if [ -f $PROFILE_FILE ]; then
+ if [ -f "$PROFILE_FILE" ]; then
echo "Loading profile at ${PROFILE_FILE}..."
. $PROFILE_FILE
- if [ "x$APN" != "x" ]; then
+ if [ -n "$APN" ]; then
echo " APN: $APN"
else
echo " APN: unset"
fi
- if [ "x$PROXY" = "xyes" ]; then
+ if [ "$PROXY" = "yes" ]; then
echo " qmi-proxy: $PROXY"
PROXY_OPT='--device-open-proxy'
else
@@ -163,31 +163,31 @@ save_state ()
echo "Saving state at ${STATE_FILE}... ($KEY: $VAL)"
- if [ -f $STATE_FILE ]; then
+ if [ -f "$STATE_FILE" ]; then
PREVIOUS=`cat $STATE_FILE`
PREVIOUS=`echo "$PREVIOUS" | grep -v $KEY`
- if [ "x$PREVIOUS" != "x" ]; then
+ if [ -n "$PREVIOUS" ]; then
echo $PREVIOUS > $STATE_FILE
else
rm $STATE_FILE
fi
fi
- if [ "x$VAL" != "x" ]; then
+ if [ -n "$VAL" ]; then
echo "$KEY=\"$VAL\"" >> $STATE_FILE
fi
}
load_state ()
{
- if [ -f $STATE_FILE ]; then
+ if [ -f "$STATE_FILE" ]; then
echo "Loading previous state from ${STATE_FILE}..."
. $STATE_FILE
- if [ "x$CID" != "x" ]; then
+ if [ -n "$CID" ]; then
echo " Previous CID: $CID"
fi
- if [ "x$PDH" != "x" ]; then
+ if [ -n "$PDH" ]; then
echo " Previous PDH: $PDH"
fi
fi
@@ -207,7 +207,7 @@ setup_data_format ()
DEVICE_DATA_FORMAT_CMD="qmicli -d $DEVICE --wda-get-data-format $PROXY_OPT"
echo "Checking data format with '$DEVICE_DATA_FORMAT_CMD'..."
- if [ "x$QMIDEBUG" != "x" ]; then
+ if [ -n "$QMIDEBUG" ]; then
DEVICE_DATA_FORMAT_OUT="\
[/dev/cdc-wdm1] Successfully got data format
QoS flow header: no
@@ -222,7 +222,7 @@ Downlink data aggregation max size: '0'"
fi
DEVICE_LLP=`echo "$DEVICE_DATA_FORMAT_OUT" | sed -n "s/.*Link layer protocol:.*'\(.*\)'.*/\1/p"`
- if [ "x$DEVICE_LLP" = "x" ]; then
+ if [ -z "$DEVICE_LLP" ]; then
echo "Device link layer protocol not retrieved: WDA unsupported" 1>&2
return
fi
@@ -237,7 +237,7 @@ Downlink data aggregation max size: '0'"
EXPECTED_DATA_FORMAT_CMD="qmicli -d $DEVICE --get-expected-data-format"
echo "Getting expected data format with '$EXPECTED_DATA_FORMAT_CMD'..."
- if [ "x$QMIDEBUG" != "x" ]; then
+ if [ -n "$QMIDEBUG" ]; then
EXPECTED_LLP="raw-ip"
else
EXPECTED_DATA_FORMAT_OUT=`$EXPECTED_DATA_FORMAT_CMD`
@@ -266,7 +266,7 @@ Downlink data aggregation max size: '0'"
if [ $RUN_WDA -eq 1 ]; then
DEVICE_DATA_FORMAT_SET_CMD="qmicli -d $DEVICE --wda-set-data-format=$EXPECTED_LLP $PROXY_OPT"
echo "Updating device link layer protocol with '$DEVICE_DATA_FORMAT_SET_CMD'..."
- if [ "x$QMIDEBUG" != "x" ]; then
+ if [ -n "$QMIDEBUG" ]; then
DEVICE_DATA_FORMAT_SET_OUT="\
[/dev/cdc-wdm1] Successfully set data format
QoS flow header: no
@@ -281,7 +281,7 @@ Downlink data aggregation max datagrams: '0'
fi
LLP=`echo "$DEVICE_DATA_FORMAT_SET_OUT" | sed -n "s/.*Link layer protocol:.*'\(.*\)'.*/\1/p"`
- if [ "x$LLP" = "x" ]; then
+ if [ -z "$LLP" ]; then
echo "Error updating Device link layer protocol" 1>&2
else
echo "New device link layer protocol retrieved: $LLP"
@@ -306,11 +306,11 @@ Downlink data aggregation max datagrams: '0'
# CID: '80'
start_network ()
{
- if [ "x$CID" != "x" ]; then
+ if [ -n "$CID" ]; then
USE_PREVIOUS_CID="--client-cid=$CID"
fi
- if [ "x$PDH" != "x" ]; then
+ if [ -n "$PDH" ]; then
echo "error: cannot re-start network, PDH already exists" 1>&2
exit 3
fi
@@ -320,7 +320,7 @@ start_network ()
START_NETWORK_CMD="qmicli -d $DEVICE --wds-start-network=$APN $USE_PREVIOUS_CID --client-no-release-cid $PROXY_OPT"
echo "Starting network with '$START_NETWORK_CMD'..."
- if [ "x$QMIDEBUG" != "x" ]; then
+ if [ -n "$QMIDEBUG" ]; then
START_NETWORK_OUT="\
[/dev/cdc-wdm0] Network started
Packet data handle: '3634026241'
@@ -332,9 +332,9 @@ start_network ()
fi
# Save the new CID if we didn't use any before
- if [ "x$CID" = "x" ]; then
+ if [ -z "$CID" ]; then
CID=`echo "$START_NETWORK_OUT" | sed -n "s/.*CID.*'\(.*\)'.*/\1/p"`
- if [ "x$CID" = "x" ]; then
+ if [ -z "$CID" ]; then
echo "error: network start failed, client not allocated" 1>&2
exit 1
else
@@ -343,7 +343,7 @@ start_network ()
fi
PDH=`echo "$START_NETWORK_OUT" | sed -n "s/.*handle.*'\(.*\)'.*/\1/p"`
- if [ "x$PDH" = "x" ]; then
+ if [ -z "$PDH" ]; then
echo "error: network start failed, no packet data handle" 1>&2
# Cleanup the client
qmicli -d "$DEVICE" --wds-noop --client-cid="$CID" $PROXY_OPT
@@ -359,9 +359,9 @@ start_network ()
# qmicli -d /dev/cdc-wdm0 --wds-stop-network
stop_network ()
{
- if [ "x$CID" = "x" ]; then
+ if [ -z "$CID" ]; then
echo "Network already stopped"
- elif [ "x$PDH" = "x" ]; then
+ elif [ -z "$PDH" ]; then
echo "Network already stopped; need to cleanup CID $CID"
# Cleanup the client
qmicli -d "$DEVICE" --wds-noop --client-cid="$CID" $PROXY_OPT
@@ -369,7 +369,7 @@ stop_network ()
STOP_NETWORK_CMD="qmicli -d $DEVICE --wds-stop-network=$PDH --client-cid=$CID $PROXY_OPT"
echo "Stopping network with '$STOP_NETWORK_CMD'..."
- if [ "x$QMIDEBUG" != "x" ]; then
+ if [ -n "$QMIDEBUG" ]; then
STOP_NETWORK_OUT="\
[/dev/cdc-wdm0] Network stopped
"
@@ -386,14 +386,14 @@ stop_network ()
# qmicli -d /dev/cdc-wdm0 --wds-get-packet-service-status
packet_service_status ()
{
- if [ "x$CID" != "x" ]; then
+ if [ -n "$CID" ]; then
USE_PREVIOUS_CID="--client-cid=$CID --client-no-release-cid"
fi
STATUS_CMD="qmicli -d $DEVICE --wds-get-packet-service-status $USE_PREVIOUS_CID $PROXY_OPT"
echo "Getting status with '$STATUS_CMD'..."
- if [ "x$QMIDEBUG" != "x" ]; then
+ if [ -n "$QMIDEBUG" ]; then
STATUS_OUT="\
[/dev/cdc-wdm0] Connection status: 'disconnected'
"
@@ -402,12 +402,12 @@ packet_service_status ()
fi
CONN=`echo "$STATUS_OUT" | sed -n "s/.*Connection status:.*'\(.*\)'.*/\1/p"`
- if [ "x$CONN" = "x" ]; then
+ if [ -z "$CONN" ]; then
echo "error: couldn't get packet service status" 1>&2
exit 2
else
echo "Status: $CONN"
- if [ "x$CONN" != "xconnected" ]; then
+ if [ "$CONN" != "connected" ]; then
exit 64
fi
fi