mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-02-24 17:57:03 +00:00
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:
@@ -48,6 +48,7 @@ _log() {
|
|||||||
else
|
else
|
||||||
echo " [ok] $1"
|
echo " [ok] $1"
|
||||||
fi
|
fi
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
remove_old_submodule() {
|
remove_old_submodule() {
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ x-path-prepend()
|
|||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to set environment variables based on the shell
|
# Function to set environment variables based on the shell
|
||||||
@@ -55,6 +56,7 @@ x-set-env()
|
|||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Explicitly set XDG folders, if not already set
|
# Explicitly set XDG folders, if not already set
|
||||||
@@ -149,6 +151,7 @@ if ! declare -f array_diff > /dev/null; then
|
|||||||
eval local ARR2=\(\"\${$3[@]}\"\)
|
eval local ARR2=\(\"\${$3[@]}\"\)
|
||||||
local IFS=$'\n'
|
local IFS=$'\n'
|
||||||
mapfile -t "$1" < <(comm -23 <(echo "${ARR1[*]}" | sort) <(echo "${ARR2[*]}" | sort))
|
mapfile -t "$1" < <(comm -23 <(echo "${ARR1[*]}" | sort) <(echo "${ARR2[*]}" | sort))
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ pick_with_gum() {
|
|||||||
--placeholder 'Pick a sesh' \
|
--placeholder 'Pick a sesh' \
|
||||||
--height 50 \
|
--height 50 \
|
||||||
--prompt='⚡'
|
--prompt='⚡'
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
FZF_COMMON_OPTS=(
|
FZF_COMMON_OPTS=(
|
||||||
@@ -42,10 +43,12 @@ FZF_COMMON_OPTS=(
|
|||||||
|
|
||||||
pick_with_fzf_tmux() {
|
pick_with_fzf_tmux() {
|
||||||
sesh list --icons | fzf-tmux -p 80%,70% "${FZF_COMMON_OPTS[@]}"
|
sesh list --icons | fzf-tmux -p 80%,70% "${FZF_COMMON_OPTS[@]}"
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
pick_with_fzf() {
|
pick_with_fzf() {
|
||||||
sesh list --icons | fzf "${FZF_COMMON_OPTS[@]}"
|
sesh list --icons | fzf "${FZF_COMMON_OPTS[@]}"
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
pick_with_select() {
|
pick_with_select() {
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ main()
|
|||||||
&& mv "${DEST}.tmp" "$DEST"
|
&& mv "${DEST}.tmp" "$DEST"
|
||||||
|
|
||||||
msg "Neovim keybindings documentation generated at $DEST"
|
msg "Neovim keybindings documentation generated at $DEST"
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ main()
|
|||||||
printf "\`\`\`\n\n- Generated on %s\n" "$(date)" >> "$DEST"
|
printf "\`\`\`\n\n- Generated on %s\n" "$(date)" >> "$DEST"
|
||||||
|
|
||||||
msg "wezterm keybindings documentation generated at $DEST"
|
msg "wezterm keybindings documentation generated at $DEST"
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|||||||
@@ -64,12 +64,14 @@ install_packages()
|
|||||||
else
|
else
|
||||||
msgr ok "All packages already installed"
|
msgr ok "All packages already installed"
|
||||||
fi
|
fi
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
install_packages
|
install_packages
|
||||||
msgr yay "apt package installations complete"
|
msgr yay "apt package installations complete"
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ install_packages()
|
|||||||
msgr run_done "Done installing $pkg"
|
msgr run_done "Done installing $pkg"
|
||||||
echo ""
|
echo ""
|
||||||
done
|
done
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to perform additional steps for installed cargo packages
|
# Function to perform additional steps for installed cargo packages
|
||||||
@@ -72,6 +73,7 @@ post_install_steps()
|
|||||||
msgr run "Removing cargo cache"
|
msgr run "Removing cargo cache"
|
||||||
cargo cache --autoclean
|
cargo cache --autoclean
|
||||||
msgr "done" "Done removing cargo cache"
|
msgr "done" "Done removing cargo cache"
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main()
|
||||||
@@ -79,6 +81,7 @@ main()
|
|||||||
install_packages
|
install_packages
|
||||||
msgr "done" "Installed cargo packages!"
|
msgr "done" "Installed cargo packages!"
|
||||||
post_install_steps
|
post_install_steps
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ check_required_tools()
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
clone_or_update_repo()
|
clone_or_update_repo()
|
||||||
@@ -34,6 +35,7 @@ clone_or_update_repo()
|
|||||||
git -C "$PBB_TEMP_DIR" pull -q \
|
git -C "$PBB_TEMP_DIR" pull -q \
|
||||||
&& msgr yay "Updated $PBB_GIT"
|
&& msgr yay "Updated $PBB_GIT"
|
||||||
fi
|
fi
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
prepare_cheat_dest()
|
prepare_cheat_dest()
|
||||||
@@ -46,6 +48,7 @@ prepare_cheat_dest()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$cheat_dest"
|
echo "$cheat_dest"
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Processes chapter files from the pure-bash-bible repository and generates or updates corresponding cheat sheets.
|
# 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"
|
printf '%s\n%b%s\n%s' "---" "$metadata" "---" "$(cat "$cheat_file")" > "$cheat_file"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main()
|
||||||
@@ -96,6 +100,7 @@ main()
|
|||||||
check_required_tools
|
check_required_tools
|
||||||
clone_or_update_repo
|
clone_or_update_repo
|
||||||
process_chapters
|
process_chapters
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ install_dev_tools_group()
|
|||||||
msgr run "Installing @development-tools group"
|
msgr run "Installing @development-tools group"
|
||||||
sudo dnf group install -y "Development Tools"
|
sudo dnf group install -y "Development Tools"
|
||||||
fi
|
fi
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
install_packages()
|
install_packages()
|
||||||
@@ -71,6 +72,7 @@ install_packages()
|
|||||||
else
|
else
|
||||||
msgr ok "All packages already installed"
|
msgr ok "All packages already installed"
|
||||||
fi
|
fi
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main()
|
||||||
@@ -78,6 +80,7 @@ main()
|
|||||||
install_dev_tools_group
|
install_dev_tools_group
|
||||||
install_packages
|
install_packages
|
||||||
msgr yay "dnf package installations complete"
|
msgr yay "dnf package installations complete"
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ clone_or_update_repo()
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
cd "$TMP_PATH" || { msgr err "No such folder $TMP_PATH"; exit 1; }
|
cd "$TMP_PATH" || { msgr err "No such folder $TMP_PATH"; exit 1; }
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to add fonts to sparse-checkout
|
# Function to add fonts to sparse-checkout
|
||||||
@@ -38,6 +39,7 @@ add_fonts_to_sparse_checkout()
|
|||||||
git sparse-checkout add "patched-fonts/$font"
|
git sparse-checkout add "patched-fonts/$font"
|
||||||
echo ""
|
echo ""
|
||||||
done
|
done
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to install NerdFonts
|
# Function to install NerdFonts
|
||||||
@@ -47,11 +49,13 @@ install_fonts()
|
|||||||
# shellcheck disable=SC2048,SC2086
|
# shellcheck disable=SC2048,SC2086
|
||||||
./install.sh -q -s ${fonts[*]}
|
./install.sh -q -s ${fonts[*]}
|
||||||
msgr run_done "Done"
|
msgr run_done "Done"
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
remove_tmp_path()
|
remove_tmp_path()
|
||||||
{
|
{
|
||||||
rm -rf "$TMP_PATH"
|
rm -rf "$TMP_PATH"
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main()
|
||||||
@@ -60,6 +64,7 @@ main()
|
|||||||
add_fonts_to_sparse_checkout
|
add_fonts_to_sparse_checkout
|
||||||
install_fonts
|
install_fonts
|
||||||
remove_tmp_path
|
remove_tmp_path
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|||||||
@@ -45,12 +45,14 @@ install_extensions()
|
|||||||
gh extension install "$ext"
|
gh extension install "$ext"
|
||||||
echo ""
|
echo ""
|
||||||
done
|
done
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
install_extensions
|
install_extensions
|
||||||
msgr run_done "Done"
|
msgr run_done "Done"
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ install_packages()
|
|||||||
go install "$pkg"
|
go install "$pkg"
|
||||||
echo ""
|
echo ""
|
||||||
done
|
done
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to install completions and run actions for selected packages
|
# 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" \
|
git-profile completion zsh > "$ZSH_CUSTOM_COMPLETION_PATH/_git-profile" \
|
||||||
&& msgr run_done "Installed completions for git-profile"
|
&& msgr run_done "Installed completions for git-profile"
|
||||||
fi
|
fi
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to clear go cache
|
# Function to clear go cache
|
||||||
@@ -51,6 +53,7 @@ clear_go_cache()
|
|||||||
{
|
{
|
||||||
msgr run "Clearing go cache"
|
msgr run "Clearing go cache"
|
||||||
go clean -cache -modcache
|
go clean -cache -modcache
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main()
|
||||||
@@ -59,6 +62,7 @@ main()
|
|||||||
post_install
|
post_install
|
||||||
clear_go_cache
|
clear_go_cache
|
||||||
msgr run_done "Done"
|
msgr run_done "Done"
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ install_packages()
|
|||||||
fi
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
done
|
done
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to upgrade all global npm packages
|
# Function to upgrade all global npm packages
|
||||||
@@ -44,6 +45,7 @@ upgrade_global_packages()
|
|||||||
msgr run "Upgrading all global packages"
|
msgr run "Upgrading all global packages"
|
||||||
npm -g --no-progress --no-timing --no-fund outdated
|
npm -g --no-progress --no-timing --no-fund outdated
|
||||||
npm -g --no-timing --no-fund upgrade
|
npm -g --no-timing --no-fund upgrade
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to clean npm cache
|
# Function to clean npm cache
|
||||||
@@ -53,6 +55,7 @@ clean_npm_cache()
|
|||||||
npm cache verify
|
npm cache verify
|
||||||
npm cache clean --force
|
npm cache clean --force
|
||||||
npm cache verify
|
npm cache verify
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main()
|
||||||
@@ -61,6 +64,7 @@ main()
|
|||||||
upgrade_global_packages
|
upgrade_global_packages
|
||||||
clean_npm_cache
|
clean_npm_cache
|
||||||
msgr yay "npm package installations complete"
|
msgr yay "npm package installations complete"
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|||||||
@@ -46,12 +46,14 @@ install_ntfy()
|
|||||||
if [[ ! -f "$HOME/.config/ntfy/client.yml" ]]; then
|
if [[ ! -f "$HOME/.config/ntfy/client.yml" ]]; then
|
||||||
cp "$tmpdir/${NTFY_DIR}/client/client.yml" ~/.config/ntfy/client.yml
|
cp "$tmpdir/${NTFY_DIR}/client/client.yml" ~/.config/ntfy/client.yml
|
||||||
fi
|
fi
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
install_ntfy
|
install_ntfy
|
||||||
msgr "done" "ntfy installation complete"
|
msgr "done" "ntfy installation complete"
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ install_tools()
|
|||||||
uv tool install --upgrade "$pkg"
|
uv tool install --upgrade "$pkg"
|
||||||
echo ""
|
echo ""
|
||||||
done
|
done
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to install library packages via uv pip install
|
# Function to install library packages via uv pip install
|
||||||
@@ -56,6 +57,7 @@ install_libraries()
|
|||||||
uv pip install --system --upgrade "$pkg"
|
uv pip install --system --upgrade "$pkg"
|
||||||
echo ""
|
echo ""
|
||||||
done
|
done
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to upgrade all uv-managed tools
|
# Function to upgrade all uv-managed tools
|
||||||
@@ -63,6 +65,7 @@ upgrade_tools()
|
|||||||
{
|
{
|
||||||
msgr run "Upgrading all uv-managed tools"
|
msgr run "Upgrading all uv-managed tools"
|
||||||
uv tool upgrade --all
|
uv tool upgrade --all
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main()
|
||||||
@@ -71,6 +74,7 @@ main()
|
|||||||
install_libraries
|
install_libraries
|
||||||
upgrade_tools
|
upgrade_tools
|
||||||
msgr yay "Python package installations complete"
|
msgr yay "Python package installations complete"
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ keep_alive_sudo()
|
|||||||
sleep 60
|
sleep 60
|
||||||
kill -0 "$$" || exit
|
kill -0 "$$" || exit
|
||||||
done 2> /dev/null &
|
done 2> /dev/null &
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
XCODE_TOOLS_PATH="$(xcode-select -p)"
|
XCODE_TOOLS_PATH="$(xcode-select -p)"
|
||||||
@@ -46,6 +47,7 @@ prompt_xcode_install()
|
|||||||
msgr warn "You have cancelled the installation, please rerun the installer."
|
msgr warn "You have cancelled the installation, please rerun the installer."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Main function
|
# Main function
|
||||||
@@ -63,6 +65,7 @@ main()
|
|||||||
echo -n "."
|
echo -n "."
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|||||||
@@ -20,12 +20,14 @@ clone_z_repo()
|
|||||||
else
|
else
|
||||||
msgr ok "z ($bin_path/) already installed"
|
msgr ok "z ($bin_path/) already installed"
|
||||||
fi
|
fi
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Main function
|
# Main function
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
clone_z_repo "$Z_GIT_PATH" "$Z_BIN_PATH"
|
clone_z_repo "$Z_GIT_PATH" "$Z_BIN_PATH"
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|||||||
Reference in New Issue
Block a user