fix(shell): add explicit return statements to functions

Add return 0 as the last statement in ~46 shell functions across
17 files that previously relied on implicit return codes
(SonarCloud rule shelldre:S7682).
This commit is contained in:
2026-02-07 14:00:58 +02:00
parent 63a21d08b4
commit 473fc820b9
17 changed files with 48 additions and 0 deletions

View File

@@ -48,6 +48,7 @@ _log() {
else
echo " [ok] $1"
fi
return 0
}
remove_old_submodule() {

View File

@@ -36,6 +36,7 @@ x-path-prepend()
exit 1
;;
esac
return 0
}
# Function to set environment variables based on the shell
@@ -55,6 +56,7 @@ x-set-env()
exit 1
;;
esac
return 0
}
# Explicitly set XDG folders, if not already set
@@ -149,6 +151,7 @@ if ! declare -f array_diff > /dev/null; then
eval local ARR2=\(\"\${$3[@]}\"\)
local IFS=$'\n'
mapfile -t "$1" < <(comm -23 <(echo "${ARR1[*]}" | sort) <(echo "${ARR2[*]}" | sort))
return 0
}
fi

View File

@@ -22,6 +22,7 @@ pick_with_gum() {
--placeholder 'Pick a sesh' \
--height 50 \
--prompt='⚡'
return 0
}
FZF_COMMON_OPTS=(
@@ -42,10 +43,12 @@ FZF_COMMON_OPTS=(
pick_with_fzf_tmux() {
sesh list --icons | fzf-tmux -p 80%,70% "${FZF_COMMON_OPTS[@]}"
return 0
}
pick_with_fzf() {
sesh list --icons | fzf "${FZF_COMMON_OPTS[@]}"
return 0
}
pick_with_select() {

View File

@@ -28,6 +28,7 @@ main()
&& mv "${DEST}.tmp" "$DEST"
msg "Neovim keybindings documentation generated at $DEST"
return 0
}
main "$@"

View File

@@ -20,6 +20,7 @@ main()
printf "\`\`\`\n\n- Generated on %s\n" "$(date)" >> "$DEST"
msg "wezterm keybindings documentation generated at $DEST"
return 0
}
main "$@"

View File

@@ -64,12 +64,14 @@ install_packages()
else
msgr ok "All packages already installed"
fi
return 0
}
main()
{
install_packages
msgr yay "apt package installations complete"
return 0
}
main "$@"

View File

@@ -57,6 +57,7 @@ install_packages()
msgr run_done "Done installing $pkg"
echo ""
done
return 0
}
# Function to perform additional steps for installed cargo packages
@@ -72,6 +73,7 @@ post_install_steps()
msgr run "Removing cargo cache"
cargo cache --autoclean
msgr "done" "Done removing cargo cache"
return 0
}
main()
@@ -79,6 +81,7 @@ main()
install_packages
msgr "done" "Installed cargo packages!"
post_install_steps
return 0
}
main "$@"

View File

@@ -20,6 +20,7 @@ check_required_tools()
exit 1
fi
done
return 0
}
clone_or_update_repo()
@@ -34,6 +35,7 @@ clone_or_update_repo()
git -C "$PBB_TEMP_DIR" pull -q \
&& msgr yay "Updated $PBB_GIT"
fi
return 0
}
prepare_cheat_dest()
@@ -46,6 +48,7 @@ prepare_cheat_dest()
fi
echo "$cheat_dest"
return 0
}
# Processes chapter files from the pure-bash-bible repository and generates or updates corresponding cheat sheets.
@@ -89,6 +92,7 @@ process_chapters()
printf '%s\n%b%s\n%s' "---" "$metadata" "---" "$(cat "$cheat_file")" > "$cheat_file"
fi
done
return 0
}
main()
@@ -96,6 +100,7 @@ main()
check_required_tools
clone_or_update_repo
process_chapters
return 0
}
main "$@"

View File

@@ -47,6 +47,7 @@ install_dev_tools_group()
msgr run "Installing @development-tools group"
sudo dnf group install -y "Development Tools"
fi
return 0
}
install_packages()
@@ -71,6 +72,7 @@ install_packages()
else
msgr ok "All packages already installed"
fi
return 0
}
main()
@@ -78,6 +80,7 @@ main()
install_dev_tools_group
install_packages
msgr yay "dnf package installations complete"
return 0
}
main "$@"

View File

@@ -23,6 +23,7 @@ clone_or_update_repo()
fi
cd "$TMP_PATH" || { msgr err "No such folder $TMP_PATH"; exit 1; }
return 0
}
# Function to add fonts to sparse-checkout
@@ -38,6 +39,7 @@ add_fonts_to_sparse_checkout()
git sparse-checkout add "patched-fonts/$font"
echo ""
done
return 0
}
# Function to install NerdFonts
@@ -47,11 +49,13 @@ install_fonts()
# shellcheck disable=SC2048,SC2086
./install.sh -q -s ${fonts[*]}
msgr run_done "Done"
return 0
}
remove_tmp_path()
{
rm -rf "$TMP_PATH"
return 0
}
main()
@@ -60,6 +64,7 @@ main()
add_fonts_to_sparse_checkout
install_fonts
remove_tmp_path
return 0
}
main "$@"

View File

@@ -45,12 +45,14 @@ install_extensions()
gh extension install "$ext"
echo ""
done
return 0
}
main()
{
install_extensions
msgr run_done "Done"
return 0
}
main "$@"

View File

@@ -33,6 +33,7 @@ install_packages()
go install "$pkg"
echo ""
done
return 0
}
# Function to install completions and run actions for selected packages
@@ -44,6 +45,7 @@ post_install()
git-profile completion zsh > "$ZSH_CUSTOM_COMPLETION_PATH/_git-profile" \
&& msgr run_done "Installed completions for git-profile"
fi
return 0
}
# Function to clear go cache
@@ -51,6 +53,7 @@ clear_go_cache()
{
msgr run "Clearing go cache"
go clean -cache -modcache
return 0
}
main()
@@ -59,6 +62,7 @@ main()
post_install
clear_go_cache
msgr run_done "Done"
return 0
}
main "$@"

View File

@@ -36,6 +36,7 @@ install_packages()
fi
echo ""
done
return 0
}
# Function to upgrade all global npm packages
@@ -44,6 +45,7 @@ upgrade_global_packages()
msgr run "Upgrading all global packages"
npm -g --no-progress --no-timing --no-fund outdated
npm -g --no-timing --no-fund upgrade
return 0
}
# Function to clean npm cache
@@ -53,6 +55,7 @@ clean_npm_cache()
npm cache verify
npm cache clean --force
npm cache verify
return 0
}
main()
@@ -61,6 +64,7 @@ main()
upgrade_global_packages
clean_npm_cache
msgr yay "npm package installations complete"
return 0
}
main "$@"

View File

@@ -46,12 +46,14 @@ install_ntfy()
if [[ ! -f "$HOME/.config/ntfy/client.yml" ]]; then
cp "$tmpdir/${NTFY_DIR}/client/client.yml" ~/.config/ntfy/client.yml
fi
return 0
}
main()
{
install_ntfy
msgr "done" "ntfy installation complete"
return 0
}
main "$@"

View File

@@ -40,6 +40,7 @@ install_tools()
uv tool install --upgrade "$pkg"
echo ""
done
return 0
}
# Function to install library packages via uv pip install
@@ -56,6 +57,7 @@ install_libraries()
uv pip install --system --upgrade "$pkg"
echo ""
done
return 0
}
# Function to upgrade all uv-managed tools
@@ -63,6 +65,7 @@ upgrade_tools()
{
msgr run "Upgrading all uv-managed tools"
uv tool upgrade --all
return 0
}
main()
@@ -71,6 +74,7 @@ main()
install_libraries
upgrade_tools
msgr yay "Python package installations complete"
return 0
}
main "$@"

View File

@@ -27,6 +27,7 @@ keep_alive_sudo()
sleep 60
kill -0 "$$" || exit
done 2> /dev/null &
return 0
}
XCODE_TOOLS_PATH="$(xcode-select -p)"
@@ -46,6 +47,7 @@ prompt_xcode_install()
msgr warn "You have cancelled the installation, please rerun the installer."
exit 1
fi
return 0
}
# Main function
@@ -63,6 +65,7 @@ main()
echo -n "."
sleep 1
done
return 0
}
main "$@"

View File

@@ -20,12 +20,14 @@ clone_z_repo()
else
msgr ok "z ($bin_path/) already installed"
fi
return 0
}
# Main function
main()
{
clone_z_repo "$Z_GIT_PATH" "$Z_BIN_PATH"
return 0
}
main "$@"