From 83c51c9d84413690c45539adb3119d031e14e7e9 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Tue, 8 Apr 2025 10:59:10 +0200 Subject: [PATCH] Lint SC2236 --- .templates/00-banner.sh | 8 ++++---- .templates/90-dns_set.sh | 2 +- .templates/ha_lsio.sh | 2 +- birdnet-pi/rootfs/etc/cont-init.d/99-run.sh | 2 +- birdnet-pi/rootfs/helpers/spectral_analysis.sh | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.templates/00-banner.sh b/.templates/00-banner.sh index 7f2aa2c5b..26bf37509 100755 --- a/.templates/00-banner.sh +++ b/.templates/00-banner.sh @@ -18,8 +18,8 @@ if ! bashio::supervisor.ping 2>/dev/null; then echo "... convert scripts to use environment variables instead of addon options" while IFS= read -r scripts do - sed -i -e 's/bashio::config.has_value[[:space:]]*["'"'"']\([^"'"'"']*\)["'"'"']/[ ! -z "${\1:-}" ]/g' \ - -e 's/bashio::config.true[[:space:]]*["'"'"']\([^"'"'"']*\)["'"'"']/[ ! -z "${\1:-}" ] \&\& [ "${\1:-}" = "true" ]/g' \ + sed -i -e 's/bashio::config.has_value[[:space:]]*["'"'"']\([^"'"'"']*\)["'"'"']/[ -n "${\1:-}" ]/g' \ + -e 's/bashio::config.true[[:space:]]*["'"'"']\([^"'"'"']*\)["'"'"']/[ -n "${\1:-}" ] \&\& [ "${\1:-}" = "true" ]/g' \ -e 's/\$(bashio::config[[:space:]]*["'"'"']\([^"'"'"']*\)["'"'"'])/${\1:-}/g' \ -e 's/\$(bashio::addon.port[[:space:]]*["'"'"']\([0-9]*\)["'"'"'])/${\1:-}/g' \ -e 's/bashio::config.require.ssl/true/g' \ @@ -74,7 +74,7 @@ if bashio::config.has_value "PUID" && bashio::config.has_value "PGID"; then PGID="$(bashio::config "PGID")" bashio::log.blue "User UID: $PUID" bashio::log.blue "User GID: $PGID" - + # Only modify user/group if they exist if id abc &>/dev/null; then usermod -o -u "$PUID" abc &>/dev/null @@ -82,7 +82,7 @@ if bashio::config.has_value "PUID" && bashio::config.has_value "PGID"; then if getent group abc &>/dev/null; then groupmod -o -g "$PGID" abc &>/dev/null fi - + bashio::log.blue \ '-----------------------------------------------------------' fi diff --git a/.templates/90-dns_set.sh b/.templates/90-dns_set.sh index 157dd4666..487deb4a9 100755 --- a/.templates/90-dns_set.sh +++ b/.templates/90-dns_set.sh @@ -29,7 +29,7 @@ if bashio::config.has_value 'DNS_server'; then # Only add DNS if there are DNS set # shellcheck disable=SC2236 - if [[ ! -z "$DNS" ]]; then + if [[ -n "${DNS:-}" ]]; then # Write resolv.conf # shellcheck disable=SC2059 printf "${DNS}" >/etc/resolv.conf diff --git a/.templates/ha_lsio.sh b/.templates/ha_lsio.sh index 5ee75a756..9d6ebd4f1 100755 --- a/.templates/ha_lsio.sh +++ b/.templates/ha_lsio.sh @@ -39,7 +39,7 @@ done # Avoid chmod /config if ha config mounted if [ -f /config/configuration.yaml ] || [ -f /config/configuration.json ]; then for file in /etc/services.d/*/* /etc/cont-init.d/* /etc/s6-overlay/s6-rc.d/*/*; do - if [ -f "$file" ] && [ ! -z "$(awk '/chown.*abc:abc.*\\/,/.*\/config( |$)/{print FILENAME}' "$file")" ]; then + if [ -f "$file" ] && [ -n "$(awk '/chown.*abc:abc.*\\/,/.*\/config( |$)/{print FILENAME}' "$file")" ]; then sed -i "s|/config$|/data|g" "$file" fi done diff --git a/birdnet-pi/rootfs/etc/cont-init.d/99-run.sh b/birdnet-pi/rootfs/etc/cont-init.d/99-run.sh index ae13b9487..b28838b5a 100755 --- a/birdnet-pi/rootfs/etc/cont-init.d/99-run.sh +++ b/birdnet-pi/rootfs/etc/cont-init.d/99-run.sh @@ -58,7 +58,7 @@ else fi || true # Use ALSA CARD defined in add-on options if available -if [ ! -z "${ALSA_CARD:-}" ]; then +if [ -n "${ALSA_CARD:-}" ]; then bashio::log.warning "ALSA_CARD is defined, the birdnet.conf is adapt to use device $ALSA_CARD" for file in "$HOME"/BirdNET-Pi/birdnet.conf /config/birdnet.conf; do if [ -f "$file" ]; then diff --git a/birdnet-pi/rootfs/helpers/spectral_analysis.sh b/birdnet-pi/rootfs/helpers/spectral_analysis.sh index 00175bbe3..1ee848412 100755 --- a/birdnet-pi/rootfs/helpers/spectral_analysis.sh +++ b/birdnet-pi/rootfs/helpers/spectral_analysis.sh @@ -18,7 +18,7 @@ fi filename="Spectrum_$(date "+%Y-%m-%d_%H:%M").wav" -if [ ! -z "$RTSP_STREAM" ];then +if [ -n "${RTSP_STREAM:-}" ];then # Explode the RSPT steam setting into an array so we can count the number we have RTSP_STREAMS_EXPLODED_ARRAY=("${RTSP_STREAM//,/ }")