fix: guard success messages on command exit status

- Source x-path instead of capturing empty stdout via command substitution
- Validate --dry-run argument in cleanup script, reject unknown flags
- Gate success messages on preceding command's exit status with &&
- Applies to dfm (fmt, reset_nvim, shfmt) and install scripts
  (fonts, gh-extensions, python-packages, shellspec, z)
This commit is contained in:
2026-03-18 12:33:00 +02:00
parent 9df2996a5d
commit e918a41d75
8 changed files with 39 additions and 23 deletions

View File

@@ -22,7 +22,10 @@
PATH="$DOTFILES/local/bin:$PATH" PATH="$DOTFILES/local/bin:$PATH"
# Use x-path to deduplicate PATH entries (only if x-path is available) # Use x-path to deduplicate PATH entries (only if x-path is available)
if command -v x-path &> /dev/null; then if command -v x-path &> /dev/null; then
PATH="$(x-path prepend "$XDG_BIN_HOME" "$DOTFILES/local/bin" "/opt/homebrew/bin" "/usr/local/bin")" # shellcheck source=../local/bin/x-path
source "$(command -v x-path)"
normalize_path_var
do_prepend "$XDG_BIN_HOME" "$DOTFILES/local/bin" "/opt/homebrew/bin" "/usr/local/bin"
fi fi
export PATH export PATH

View File

@@ -531,9 +531,9 @@ section_dotfiles()
case "$1" in case "$1" in
fmt) fmt)
msgr run "Running all formatters" msgr run "Running all formatters"
$0 dotfiles yamlfmt $0 dotfiles yamlfmt \
$0 dotfiles shfmt && $0 dotfiles shfmt \
msgr run_done "...done!" && msgr run_done "...done!"
;; ;;
reset_all) reset_all)
@@ -547,12 +547,16 @@ section_dotfiles()
~/.local/share/nvim \ ~/.local/share/nvim \
~/.local/state/nvim \ ~/.local/state/nvim \
~/.cache/nvim \ ~/.cache/nvim \
~/.config/nvim ~/.config/nvim \
msgr ok "Deleted old nvim files (share, state and cache + config)" && msgr ok "Deleted old nvim files (share, state and cache + config)"
ln -s "$DOTFILES/config/nvim" ~/.config/nvim ln -s "$DOTFILES/config/nvim" ~/.config/nvim \
msgr ok "Linked nvim and astronvim" && msgr ok "Linked nvim and astronvim"
$0 install mise if $0 install mise; then
msgr ok "Installed packages" msgr ok "Installed packages"
else
msgr err "Failed to install mise tools"
exit 1
fi
msgr run_done "nvim reset!" msgr run_done "nvim reset!"
;; ;;
@@ -575,8 +579,8 @@ section_dotfiles()
--language-dialect bash \ --language-dialect bash \
--func-next-line --list --write \ --func-next-line --list --write \
--indent 2 --case-indent --space-redirects \ --indent 2 --case-indent --space-redirects \
--binary-next-line {} \; --binary-next-line {} \; \
msgr yay "dotfiles have been shfmt formatted!" && msgr yay "dotfiles have been shfmt formatted!"
;; ;;
*) menu_builder "$USAGE_PREFIX" "${MENU[@]}" ;; *) menu_builder "$USAGE_PREFIX" "${MENU[@]}" ;;

View File

@@ -12,7 +12,15 @@ fi
# shellcheck source=shared.sh # shellcheck source=shared.sh
source "$DOTFILES/config/shared.sh" source "$DOTFILES/config/shared.sh"
DRY_RUN="${1:-}" DRY_RUN=""
if [[ $# -gt 0 ]]; then
if [[ "$1" = "--dry-run" ]]; then
DRY_RUN="--dry-run"
else
echo "Usage: $0 [--dry-run]" >&2
exit 1
fi
fi
remove_dir() remove_dir()
{ {

View File

@@ -51,8 +51,9 @@ install_fonts()
{ {
msgr run "Starting to install NerdFonts..." msgr run "Starting to install NerdFonts..."
# shellcheck disable=SC2048,SC2086 # shellcheck disable=SC2048,SC2086
./install.sh -q -s ${fonts[*]} # shellcheck disable=SC2086
msgr run_done "Done" ./install.sh -q -s ${fonts[*]} \
&& msgr run_done "Done"
return 0 return 0
} }

View File

@@ -51,8 +51,8 @@ install_extensions()
# Install all GitHub CLI extensions # Install all GitHub CLI extensions
main() main()
{ {
install_extensions install_extensions \
msgr run_done "Done" && msgr run_done "Done"
return 0 return 0
} }

View File

@@ -35,5 +35,5 @@ install_libraries()
return 0 return 0
} }
install_libraries install_libraries \
msgr yay "Python library installations complete" && msgr yay "Python library installations complete"

View File

@@ -23,8 +23,8 @@ install_shellspec()
fi fi
msgr run "Running make install..." msgr run "Running make install..."
make -C "$SHELLSPEC_CACHE" install PREFIX="$HOME/.local" make -C "$SHELLSPEC_CACHE" install PREFIX="$HOME/.local" \
msgr run_done "shellspec $version installed to $HOME/.local/bin/shellspec" && msgr run_done "shellspec $version installed to $HOME/.local/bin/shellspec"
return 0 return 0
} }

View File

@@ -15,8 +15,8 @@ clone_z_repo()
local bin_path=$2 local bin_path=$2
if [[ ! -d "$bin_path" ]]; then if [[ ! -d "$bin_path" ]]; then
git clone "$git_path" "$bin_path" git clone "$git_path" "$bin_path" \
msgr run_done "z installed at $bin_path" && msgr run_done "z installed at $bin_path"
else else
msgr ok "z ($bin_path/) already installed" msgr ok "z ($bin_path/) already installed"
fi fi