1
0
mirror of https://github.com/morrownr/8821cu-20210916.git synced 2024-12-21 13:55:40 +00:00

Converted to non-Bash editor searching

This commit is contained in:
Miles Goodhew 2023-01-25 21:45:40 +11:00
parent 8c202dd766
commit 08c72e9cb4
2 changed files with 6 additions and 16 deletions

View File

@ -26,8 +26,7 @@
SCRIPT_NAME="edit-options.sh"
SCRIPT_VERSION="20230120"
OPTIONS_FILE="8821cu.conf"
DEFAULT_EDITOR="$(<default-editor.txt)"
EDITORS_SEARCH=("${VISUAL}" "${EDITOR}" "${DEFAULT_EDITOR}" "vi")
DEFAULT_EDITOR="$(cat default-editor.txt)"
if [[ $EUID -ne 0 ]]
then
@ -37,13 +36,9 @@ then
fi
# Try to find the user's default text editor through the EDITORS_SEARCH array
for editor in ${EDITORS_SEARCH[@]}
for TEXT_EDITOR in "${VISUAL}" "${EDITOR}" "${DEFAULT_EDITOR}" vi;
do
if command -v "${editor}" >/dev/null 2>&1
then
TEXT_EDITOR="${editor}"
break
fi
command -v "${TEXT_EDITOR}" >/dev/null 2>&1 && break
done
# Fail if no editor was found

View File

@ -38,8 +38,7 @@ OPTIONS_FILE="${MODULE_NAME}.conf"
SMEM=$(LANG=C free | awk '/Mem:/ { print $2 }')
sproc=$(nproc)
DEFAULT_EDITOR="$(<default-editor.txt)"
EDITORS_SEARCH=("${VISUAL}" "${EDITOR}" "${DEFAULT_EDITOR}" "vi")
DEFAULT_EDITOR="$(cat default-editor.txt)"
# check to ensure sudo was used
if [[ $EUID -ne 0 ]]
@ -99,13 +98,9 @@ then
fi
# Try to find the user's default text editor through the EDITORS_SEARCH array
for editor in ${EDITORS_SEARCH[@]}
for TEXT_EDITOR in "${VISUAL}" "${EDITOR}" "${DEFAULT_EDITOR}" vi;
do
if command -v "${editor}" >/dev/null 2>&1
then
TEXT_EDITOR="${editor}"
break
fi
command -v "${TEXT_EDITOR}" >/dev/null 2>&1 && break
done
# Fail if no editor was found