From 7d1454e4307617471b05fedaf831b28bee74612a Mon Sep 17 00:00:00 2001 From: aarondill Date: Wed, 5 Jul 2023 13:52:17 -0500 Subject: [PATCH] handle _man_dir writabililty more robustly This ensures that mismatched permissions/ownership on `${_man_dir}` and `${_man_dir}/man1` don't cause the script to fail. *If* `${man_dir}/man1` already exists and is writable, OR `${_man_dir}/man1` *doesn't* yet exist, but `${_man_dir}` is writable, then the script continues without sudo. If `/man1` doesn't exist, and it's parent isn't writable, we need sudo. If `/man1` *does* exist, and it's not writable, we need sudo. --- install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index baa0df4..3d2ad99 100755 --- a/install.sh +++ b/install.sh @@ -150,7 +150,8 @@ main() { # After this point, $sudo is used for _bin_dir instead of _bin_dir - if test_writeable "${_man_dir}"; then + if { [ -d "${_man_dir}/man1" ] && test_writeable "${_man_dir}/man1}"; } || + { ! [ -d "${_man_dir}/man1" ] && test_writeable "${_man_dir}"; }; then log "Installing zoxide man pages, please wait…" _sudo="" else