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
This commit is contained in:
parent
c01c75fe41
commit
8c8a0cf709
17
install.sh
17
install.sh
|
|
@ -37,13 +37,12 @@ main() {
|
||||||
local _bin_dir="${HOME}/.local/bin"
|
local _bin_dir="${HOME}/.local/bin"
|
||||||
local _bin_name
|
local _bin_name
|
||||||
local _man_dir="${HOME}/.local/share/man"
|
local _man_dir="${HOME}/.local/share/man"
|
||||||
local _sudo="sudo"
|
local _sudo
|
||||||
|
|
||||||
parse_args "$@" # sets global variables (BIN_DIR, MAN_DIR, ARCH, SUDO)
|
parse_args "$@" # sets global variables (BIN_DIR, MAN_DIR, ARCH, SUDO)
|
||||||
|
|
||||||
_bin_dir=${BIN_DIR:-$_bin_dir}
|
_bin_dir=${BIN_DIR:-$_bin_dir}
|
||||||
_man_dir=${MAN_DIR:-$_man_dir}
|
_man_dir=${MAN_DIR:-$_man_dir}
|
||||||
_sudo=${SUDO:-$_sudo}
|
|
||||||
|
|
||||||
if [ -n "${ARCH:-}" ]; then
|
if [ -n "${ARCH:-}" ]; then
|
||||||
# if the user specifed, trust them - don't error on unrecognized hardware.
|
# if the user specifed, trust them - don't error on unrecognized hardware.
|
||||||
|
|
@ -66,6 +65,7 @@ main() {
|
||||||
_sudo=''
|
_sudo=''
|
||||||
else
|
else
|
||||||
echo "Escalated permissions are required to install to ${_bin_dir}"
|
echo "Escalated permissions are required to install to ${_bin_dir}"
|
||||||
|
_sudo=${SUDO:-"sudo"}
|
||||||
if [ "${_sudo}" = 'sudo' ]; then
|
if [ "${_sudo}" = 'sudo' ]; then
|
||||||
elevate_priv # only check if the user didn't provide it, blindly trust user provided values
|
elevate_priv # only check if the user didn't provide it, blindly trust user provided values
|
||||||
fi
|
fi
|
||||||
|
|
@ -107,6 +107,19 @@ main() {
|
||||||
}
|
}
|
||||||
echo "Installed zoxide to ${_bin_dir}"
|
echo "Installed zoxide to ${_bin_dir}"
|
||||||
|
|
||||||
|
if test_writeable "${_man_dir}"; then
|
||||||
|
echo "Installing zoxide man pages, please wait…"
|
||||||
|
_sudo=""
|
||||||
|
else
|
||||||
|
echo "Escalated permissions are required to install man pages to ${_man_dir}"
|
||||||
|
_sudo=${SUDO:-"sudo"}
|
||||||
|
if [ "${_sudo}" = 'sudo' ]; then
|
||||||
|
elevate_priv # only check if the user didn't provide it, blindly trust user provided values
|
||||||
|
fi
|
||||||
|
echo "Installing zoxide man pages as root, please wait…"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Install manpages.
|
# Install manpages.
|
||||||
# shellcheck disable=SC2086 # The lack of quoting is intentional.
|
# shellcheck disable=SC2086 # The lack of quoting is intentional.
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue