From d166df7ea88640216c0d05fc64a72996ea8066ff Mon Sep 17 00:00:00 2001 From: Johannes Truschnigg Date: Sun, 4 Sep 2022 11:15:49 +0200 Subject: [PATCH] Implement a few shellcheck-suggested fixes --- sqm_lagthrottle_suggest_config.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sqm_lagthrottle_suggest_config.sh b/sqm_lagthrottle_suggest_config.sh index a88ef0d..63fdab1 100755 --- a/sqm_lagthrottle_suggest_config.sh +++ b/sqm_lagthrottle_suggest_config.sh @@ -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" -- 2.39.5