]> johannes.truschnigg.info Git - sqm_lagthrottle/commitdiff
Implement a few shellcheck-suggested fixes
authorJohannes Truschnigg <johannes@truschnigg.info>
Sun, 4 Sep 2022 09:15:49 +0000 (11:15 +0200)
committerJohannes Truschnigg <johannes@truschnigg.info>
Sun, 4 Sep 2022 09:15:49 +0000 (11:15 +0200)
sqm_lagthrottle_suggest_config.sh

index a88ef0df27a895bfc99c1312868e10251ac486e6..63fdab1a46e33f48e5e1c6228a39aca3d8f29f56 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/ash
 
 # Copyright (C)2022 Johannes Truschnigg (https://johannes.truschnigg.info/)
 #
@@ -27,13 +27,13 @@ done
 _goon() {
   echo "" >&2
   echo "${1:-Hit the [ENTER] key when ready, or [CTRL]+[C] to abort...}" >&2
-  read -s _ >/dev/null
+  read -r -s _ >/dev/null
   printf '\n\n' >&2
 }
 
 _bar() {
-  local lcnt=0
-  while [ $lcnt -lt $1 ]
+  lcnt=0
+  while [ "$lcnt" -lt "$1" ]
   do
     printf '='
     let lcnt++
@@ -71,7 +71,7 @@ if [ -e "${ifb_dev}" ]
 then
   printf 'Auto-detected downstream (rx) network device to adjust:\n\t%s\n\n' "${ifb_dev}" >&2
   printf 'Please confirm this by supplying either this sysfs path again,\nor provide a custom value to replace it:\n\t' >&2
-  read ifb_dev
+  read -r ifb_dev
 else
   printf 'FATAL: No SQM shaping (rx) network device could be determined.\nAre you sure SQM has been set up, e.g. via luci-app-sqm?\n' >&2
   exit 1
@@ -96,7 +96,7 @@ then
 else
   printf 'Failed to auto-detect a suitable upstream/tx interface.\nPlease key in the proper interface name.\n\t' >&2
 fi
-read iface_tx
+read -r iface_tx
 
 if ! [ -f /sys/class/net/"${iface_tx}"///statistics/tx_bytes ]
 then
@@ -109,14 +109,14 @@ _goon
 
 _h 'set bandwidth limits'
 printf 'Please key in the positive integer LOWER bound (=minimum) bandwidth in Kbps\nfor your downstream Internet connection that you want to shape to: ' >&2
-read bw_down_min
+read -r bw_down_min
 echo "" >&2
 
 printf 'Please key in the positive integer UPPER bound (=maximum) bandwidth in Kbps\nfor your downstream Internet connection that you want to shape to: ' >&2
-read bw_down_max
+read -r bw_down_max
 echo "" >&2
 
-if ! [ ${bw_down_min}0 -lt ${bw_down_max}0 ]
+if ! [ "${bw_down_min}"0 -lt "${bw_down_max}"0 ]
 then
   printf 'FATAL: Maximum shaping bandwidth must be greater than the minimum.\n'
   exit 1
@@ -126,7 +126,7 @@ _goon
 
 _h 'configure sqm_lagthrottle bias'
 printf 'sqm_lagthrottle can be configured to prioritize bandwidth over latency,\nor vice versa.\n\nIf you would prefer to keep the dynamic target bandwidth high even in\nthe face of worsening latency/bufferbloat, please key in "bandwidth" below.\n\nAll other inputs will lead to a preference for lower latency.\n\n\t'
-read bw_or_lat_bias
+read -r bw_or_lat_bias
 if [ x"${bw_or_lat_bias}" = xbandwidth ]
 then
   bw_or_lat_bias="bandwidth"
@@ -138,7 +138,7 @@ _goon
 
 _h 'configure sqm_lagthrottle eagerness'
 printf 'sqm_lagthrottle can be configured to be eager or relaxed\nwhen making shaper adjustment decisions.\n\nIn eager mode, decisions to try to react meaningfully to changing\ncircumstances (incrasing latency) are taken more often.\n\nIn relaxed mode, bandwidth limits will be adjusted less frequently,\nwhich MAY save some CPU time.\n\nKeying in "relaxed" below chooses that mode.\nAll other inputs will lead to eager operation.\n\n\t'
-read relaxed_or_eager
+read -r relaxed_or_eager
 if [ x"${relaxed_or_eager}" = xrelaxed ]
 then
   relaxed_or_eager="relaxed"