"Simplify" script
Thanks shfmt for pointing out these agressive simplifications that are possible, but not necisarily needed. Now can I pass CI? Please? 😄
This commit is contained in:
parent
b0ab15c6da
commit
20246a6b2b
|
|
@ -26,7 +26,7 @@ usage() {
|
||||||
# sets RETVAL to sudo command to use, exits script if no command can be found
|
# sets RETVAL to sudo command to use, exits script if no command can be found
|
||||||
# optional user command is passed as an argument, if it fails, attempts to use sudo/doas.
|
# optional user command is passed as an argument, if it fails, attempts to use sudo/doas.
|
||||||
elevate_priv() {
|
elevate_priv() {
|
||||||
if [ -n "${1:-}" ]; then # user input
|
if [ -n "${1-}" ]; then # user input
|
||||||
if "$1" true; then
|
if "$1" true; then
|
||||||
RETVAL="$1"
|
RETVAL="$1"
|
||||||
return 0
|
return 0
|
||||||
|
|
@ -72,7 +72,7 @@ main() {
|
||||||
set -u
|
set -u
|
||||||
|
|
||||||
# Detect and print host target triple.
|
# Detect and print host target triple.
|
||||||
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.
|
||||||
local _arch="${ARCH}"
|
local _arch="${ARCH}"
|
||||||
else
|
else
|
||||||
|
|
@ -90,7 +90,7 @@ main() {
|
||||||
_bin_dir=${BIN_DIR:-${_bin_dir}}
|
_bin_dir=${BIN_DIR:-${_bin_dir}}
|
||||||
_man_dir=${MAN_DIR:-${_man_dir}}
|
_man_dir=${MAN_DIR:-${_man_dir}}
|
||||||
_arch=${ARCH:-${_arch}}
|
_arch=${ARCH:-${_arch}}
|
||||||
_sudo=${SUDO:-}
|
_sudo=${SUDO-}
|
||||||
|
|
||||||
assert_nz "${_arch}" "arch"
|
assert_nz "${_arch}" "arch"
|
||||||
log "Detected architecture: ${_arch}"
|
log "Detected architecture: ${_arch}"
|
||||||
|
|
@ -156,7 +156,7 @@ main() {
|
||||||
_sudo=""
|
_sudo=""
|
||||||
else
|
else
|
||||||
log "Escalated permissions are required to install man pages to ${_man_dir}"
|
log "Escalated permissions are required to install man pages to ${_man_dir}"
|
||||||
elevate_priv "${_sudo:-${SUDO:-}}" # use previously found command OR user defined
|
elevate_priv "${_sudo:-${SUDO-}}" # use previously found command OR user defined
|
||||||
_sudo=${RETVAL}
|
_sudo=${RETVAL}
|
||||||
log "Installing zoxide man pages as root using ${_sudo}, please wait…"
|
log "Installing zoxide man pages as root using ${_sudo}, please wait…"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue