From be30f9cf193fb71663c87cd85674e03e64ff1b8b Mon Sep 17 00:00:00 2001 From: Stephan Wendel Date: Fri, 17 Dec 2021 22:09:55 +0100 Subject: [PATCH] BUGFIX: Fixes shellcheck errors. * SC2086,SC2162 and SC2250 * Affected files: * libs/logging.sh and libs/v4l2_control.sh Signed-off-by: Stephan Wendel --- libs/logging.sh | 4 ++-- libs/v4l2_control.sh | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libs/logging.sh b/libs/logging.sh index 457a908..b9fc055 100755 --- a/libs/logging.sh +++ b/libs/logging.sh @@ -37,7 +37,7 @@ function log_level { function delete_log { local devel logfile - logfile="$(get_param "webcamd" log_path | sed "s#^~#$HOME#gi")" + logfile="$(get_param "webcamd" log_path | sed "s#^~#${HOME}#gi")" devel="$(get_param "webcamd" delete_log 2> /dev/null)" if [ "${devel}" = "true" ]; then rm -rf "${logfile}" @@ -50,7 +50,7 @@ function log_msg { msg="${1}" prefix="$(date +'[%D %T]') webcamd:" #Workaround sed ~ to BASH VAR $HOME - logfile="$(get_param webcamd log_path | sed "s#^~#$HOME#gi")" + logfile="$(get_param webcamd log_path | sed "s#^~#${HOME}#gi")" #Workaround: Make Dir if not exist if [ ! -d "${logfile}" ]; then mkdir -p "$(dirname "${logfile}")" diff --git a/libs/v4l2_control.sh b/libs/v4l2_control.sh index d0eb76f..932f3af 100755 --- a/libs/v4l2_control.sh +++ b/libs/v4l2_control.sh @@ -32,18 +32,18 @@ function v4l2_control { # if not empty do if [ -n "${v4l2ctl}" ]; then # Write configured options to Log - log_msg "Device: [cam $cam]" + log_msg "Device: [cam ${cam}]" log_msg "Options: ${v4l2ctl}" # Split options to array - IFS=',' read -a opt < <(echo "${v4l2ctl}"); unset IFS + IFS=',' read -ra opt < <(echo "${v4l2ctl}"); unset IFS # loop through options for param in "${opt[@]}"; do # parameter available for device # needs || true to prevent script to exit valueless="$(echo "${param}" | cut -d "=" -f1)" - opt_avail="$(v4l2-ctl -d ${device} -L | \ - grep -c ${valueless} || true)" - if [ "$opt_avail" -eq "0" ]; then + opt_avail="$(v4l2-ctl -d "${device}" -L | \ + grep -c "${valueless}" || true)" + if [ "${opt_avail}" -eq "0" ]; then log_msg "Parameter '${param}' not available for '${device}'. Skipped." else v4l2-ctl -d "${device}" -c "${param}" 2> /dev/null