Skip to content

Commit

Permalink
dorothy: add __eval_wrap helper for debug clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
balupton committed Oct 10, 2024
1 parent 2fc7757 commit 47f29cb
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions commands/dorothy
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,16 @@ function dorothy_() (
# =====================================
# Helpers

function __eval_wrap {
# trim -- prefix
if test "${1-}" = '--'; then
shift
fi
# proceed
printf '%s\n' "$*"
"$@" # eval
}

function ensure_prereq_dependencies {
# ensure locations exist
__mkdirp "$XDG_CONFIG_HOME" "$XDG_CACHE_HOME" "$XDG_BIN_HOME" "$XDG_DATA_HOME" "$XDG_STATE_HOME"
Expand Down Expand Up @@ -583,11 +593,11 @@ function dorothy_() (
# if destination is a symlink, resolve it, move it, and remove it
if test -L "$destination"; then
if test -e "$destination"; then
temp2="$(__fs_realpath -- "$destination")"
temp="$(__fs_realpath -- "$destination")"
# remove the destination symlink
rm -f "$destination"
# relocate the target to the destination
mv -fv "$temp2" "$destination"
mv -fv "$temp" "$destination"
else
# remove the destination symlink
rm -f "$destination"
Expand Down Expand Up @@ -802,11 +812,11 @@ function dorothy_() (
"$option_branch"
)
fi
git clone "${clone_args[@]}" "https://github.com/$option_slug.git" "$DOROTHY"
__eval_wrap -- git clone "${clone_args[@]}" "https://github.com/$option_slug.git" "$DOROTHY"
if test -n "$option_reference"; then
(
cd "$DOROTHY"
git checkout --quiet "$option_reference" # --quiet to suppress "detached HEAD" feedback
__eval_wrap -- git checkout --quiet "$option_reference" # --quiet to suppress "detached HEAD" feedback
)
fi
}
Expand All @@ -831,7 +841,7 @@ function dorothy_() (
# we do not have the intelligence yet to update origin and upstream, so we will just update upstream
git remote remove "$dorothy_upstream_remote_name" 2>/dev/null || : # don't care if doesn't exist, and remove to ensure desired URL is applied
git remote add --fetch "$dorothy_upstream_remote_name" "$dorothy_upstream_git_https" || return
git pull "$dorothy_upstream_remote_name" "$dorothy_upstream_branch" || return
__eval_wrap -- git pull "$dorothy_upstream_remote_name" "$dorothy_upstream_branch" || return
__print_lines "Successfully updated Dorothy installation at $DOROTHY" || return
) || return
}
Expand Down

0 comments on commit 47f29cb

Please sign in to comment.