Shellcheck compliance

scripts/wireguard/disableCONF.sh
  * Mapfile instead of double quoted LIST=("$(...)")
scripts/wireguard/enableCONF.sh
  * SC1090: ShellCheck can't follow non-constant source. Use a directive to specify location.
    * Disabled warning
  * SC2207: Prefer mapfile or read -a to split command output (or quote to avoid splitting).
    * Changed to mapfile
  * SC2086: Double quote to prevent globbing and word splitting.
    * Added double quotes
This commit is contained in:
4s3ti 2021-11-03 15:38:45 +01:00
parent fb71fdd9fd
commit 2a78fce9d3
2 changed files with 6 additions and 5 deletions

View file

@ -58,7 +58,7 @@ if [ "$DISPLAY_DISABLED" ]; then
fi
LIST=("$(awk '{print $1}' configs/clients.txt)")
mapfile -t LIST < <(awk '{print $1}' configs/clients.txt)
if [ "${#CLIENTS_TO_CHANGE[@]}" -eq 0 ]; then
echo -e "::\e[4m Client list \e[0m::"
len=${#LIST[@]}

View file

@ -7,6 +7,7 @@ if [ ! -f "${setupVars}" ]; then
exit 1
fi
# shellcheck disable=SC1090
source "${setupVars}"
helpFunc(){
@ -55,13 +56,13 @@ if [ "$DISPLAY_DISABLED" ]; then
exit 1
fi
LIST=($(awk '{print $1}' configs/clients.txt))
mapfile -t LIST < <(awk '{print $1}' configs/clients.txt)
if [ "${#CLIENTS_TO_CHANGE[@]}" -eq 0 ]; then
echo -e "::\e[4m Client list \e[0m::"
len=${#LIST[@]}
COUNTER=1
while [ $COUNTER -le ${len} ]; do
printf "%0${#len}s) %s\r\n" ${COUNTER} ${LIST[(($COUNTER-1))]}
while [ $COUNTER -le "${len}" ]; do
printf "%0${#len}s) %s\r\n" "${COUNTER}" "${LIST[(($COUNTER-1))]}"
((COUNTER++))
done
@ -94,7 +95,7 @@ for CLIENT_NAME in "${CLIENTS_TO_CHANGE[@]}"; do
if [[ $REPLY =~ ^[Yy]$ ]]; then
# Enable the peer section from the server config
echo "${CLIENT_NAME}"
echo "${CLIENT_NAME}"
sed -e "/begin ${CLIENT_NAME}/,/end ${CLIENT_NAME}/ s/#\[disabled\] //" -i wg0.conf
echo "::: Updated server config"