From b92ff0489eba10b09837d323a2f218763e344691 Mon Sep 17 00:00:00 2001 From: aarondill Date: Wed, 5 Jul 2023 13:39:33 -0500 Subject: [PATCH] reset `$sudo` when writing man pages. This helps ensure that mismatched permission on `_bin_dir` and `_man_dir` don't cause issues. Also prevents creating man pages owned by root being written to the user's $HOME --- install.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/install.sh b/install.sh index b734e49..baa0df4 100755 --- a/install.sh +++ b/install.sh @@ -148,6 +148,18 @@ main() { } log "Installed zoxide to ${_bin_dir}" + # After this point, $sudo is used for _bin_dir instead of _bin_dir + + if test_writeable "${_man_dir}"; then + log "Installing zoxide man pages, please wait…" + _sudo="" + else + log "Escalated permissions are required to install man pages to ${_man_dir}" + elevate_priv "${_sudo:-$SUDO}" # use previously found command OR user defined + _sudo=${RETVAL} + log "Installing zoxide man pages as root using $_sudo, please wait…" + fi + # Install manpages. # shellcheck disable=SC2086 # The lack of quoting is intentional. {