mirror of
https://github.com/winapps-org/winapps.git
synced 2025-06-03 21:57:18 +02:00
Various changes to appease ShellCheck.
This commit is contained in:
parent
be5d0f4b26
commit
11d124cd0f
@ -7,7 +7,7 @@ declare -r ANSI_CLEAR_TEXT="\033[0m" # Default text.
|
|||||||
declare -r DIALOG_HEIGHT=14 # Height of dialog window.
|
declare -r DIALOG_HEIGHT=14 # Height of dialog window.
|
||||||
declare -r TEXT_WIDTH_OFFSET=4 # Offset for fitting title text.
|
declare -r TEXT_WIDTH_OFFSET=4 # Offset for fitting title text.
|
||||||
declare -r CHK_OPTION_WIDTH_OFFSET=10 # Offset for fitting options.
|
declare -r CHK_OPTION_WIDTH_OFFSET=10 # Offset for fitting options.
|
||||||
declare -r MNU_OPTION_WIDTH_OFFSET=7 # Offset for fitting options.
|
declare -r MNU_OPTION_WIDTH_OFFSET=7 # Offset for fitting options.
|
||||||
|
|
||||||
### FUNCTIONS ###
|
### FUNCTIONS ###
|
||||||
function inqMenu() {
|
function inqMenu() {
|
||||||
@ -37,7 +37,7 @@ function inqMenu() {
|
|||||||
|
|
||||||
# Find the length of the longest option to set the dialog width.
|
# Find the length of the longest option to set the dialog width.
|
||||||
for OPTION in "${TRIMMED_OPTIONS[@]}"; do
|
for OPTION in "${TRIMMED_OPTIONS[@]}"; do
|
||||||
if [ "${#OPTION}" -gt $DIALOG_WIDTH ]; then
|
if [ "${#OPTION}" -gt "$DIALOG_WIDTH" ]; then
|
||||||
DIALOG_WIDTH=${#OPTION}
|
DIALOG_WIDTH=${#OPTION}
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -53,6 +53,7 @@ function inqMenu() {
|
|||||||
# Pad option text with trailing white space to left-align all options.
|
# Pad option text with trailing white space to left-align all options.
|
||||||
for OPTION in "${TRIMMED_OPTIONS[@]}"; do
|
for OPTION in "${TRIMMED_OPTIONS[@]}"; do
|
||||||
local PAD_LENGTH=$((DIALOG_WIDTH - MNU_OPTION_WIDTH_OFFSET - ${#OPTION}))
|
local PAD_LENGTH=$((DIALOG_WIDTH - MNU_OPTION_WIDTH_OFFSET - ${#OPTION}))
|
||||||
|
# shellcheck disable=SC2155
|
||||||
local PADDED_OPTION="${OPTION}$(printf '%*s' $PAD_LENGTH)"
|
local PADDED_OPTION="${OPTION}$(printf '%*s' $PAD_LENGTH)"
|
||||||
PADDED_OPTIONS+=("$PADDED_OPTION")
|
PADDED_OPTIONS+=("$PADDED_OPTION")
|
||||||
done
|
done
|
||||||
@ -86,7 +87,7 @@ function inqMenu() {
|
|||||||
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
|
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
|
||||||
|
|
||||||
# Remove escapes (introduced by 'dialog' if options have parentheses).
|
# Remove escapes (introduced by 'dialog' if options have parentheses).
|
||||||
RETURN_STRING=$(echo "$RETURN_STRING" | sed 's/\\//g')
|
RETURN_STRING="${RETURN_STRING//\\/}" # ${variable//search/replace}
|
||||||
|
|
||||||
# Display question and response.
|
# Display question and response.
|
||||||
echo -e "${ANSI_LIGHT_GREEN}Q) ${ANSI_CLEAR_TEXT}${ANSI_LIGHT_BLUE}${DIALOG_TEXT}${ANSI_CLEAR_TEXT} --> ${ANSI_LIGHT_GREEN}${RETURN_STRING}${ANSI_CLEAR_TEXT}"
|
echo -e "${ANSI_LIGHT_GREEN}Q) ${ANSI_CLEAR_TEXT}${ANSI_LIGHT_BLUE}${DIALOG_TEXT}${ANSI_CLEAR_TEXT} --> ${ANSI_LIGHT_GREEN}${RETURN_STRING}${ANSI_CLEAR_TEXT}"
|
||||||
@ -119,7 +120,7 @@ function inqChkBx() {
|
|||||||
|
|
||||||
# Find the length of the longest option to set the dialog width.
|
# Find the length of the longest option to set the dialog width.
|
||||||
for OPTION in "${TRIMMED_OPTIONS[@]}"; do
|
for OPTION in "${TRIMMED_OPTIONS[@]}"; do
|
||||||
if [ "${#OPTION}" -gt $DIALOG_WIDTH ]; then
|
if [ "${#OPTION}" -gt "$DIALOG_WIDTH" ]; then
|
||||||
DIALOG_WIDTH=${#OPTION}
|
DIALOG_WIDTH=${#OPTION}
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -135,6 +136,7 @@ function inqChkBx() {
|
|||||||
# Pad option text with trailing white space to left-align all options.
|
# Pad option text with trailing white space to left-align all options.
|
||||||
for OPTION in "${TRIMMED_OPTIONS[@]}"; do
|
for OPTION in "${TRIMMED_OPTIONS[@]}"; do
|
||||||
local PAD_LENGTH=$((DIALOG_WIDTH - CHK_OPTION_WIDTH_OFFSET - ${#OPTION}))
|
local PAD_LENGTH=$((DIALOG_WIDTH - CHK_OPTION_WIDTH_OFFSET - ${#OPTION}))
|
||||||
|
# shellcheck disable=SC2155
|
||||||
local PADDED_OPTION="${OPTION}$(printf '%*s' $PAD_LENGTH)"
|
local PADDED_OPTION="${OPTION}$(printf '%*s' $PAD_LENGTH)"
|
||||||
PADDED_OPTIONS+=("$PADDED_OPTION")
|
PADDED_OPTIONS+=("$PADDED_OPTION")
|
||||||
done
|
done
|
||||||
@ -164,6 +166,7 @@ function inqChkBx() {
|
|||||||
2>&1 >/dev/tty) || exit 0
|
2>&1 >/dev/tty) || exit 0
|
||||||
|
|
||||||
# Convert the output string into an array.
|
# Convert the output string into an array.
|
||||||
|
# shellcheck disable=SC2001
|
||||||
while IFS= read -r LINE; do
|
while IFS= read -r LINE; do
|
||||||
LINE="${LINE/#\"}" # Remove leading double quote.
|
LINE="${LINE/#\"}" # Remove leading double quote.
|
||||||
LINE="${LINE/%\"}" # Remove trailing double quote.
|
LINE="${LINE/%\"}" # Remove trailing double quote.
|
||||||
@ -173,10 +176,11 @@ function inqChkBx() {
|
|||||||
# Final modifications.
|
# Final modifications.
|
||||||
for (( i=0; i<${#RETURN_ARRAY[@]}; i++ )); do
|
for (( i=0; i<${#RETURN_ARRAY[@]}; i++ )); do
|
||||||
# Remove white space added previously.
|
# Remove white space added previously.
|
||||||
|
# shellcheck disable=SC2001
|
||||||
RETURN_ARRAY[i]=$(echo "${RETURN_ARRAY[i]}" | \
|
RETURN_ARRAY[i]=$(echo "${RETURN_ARRAY[i]}" | \
|
||||||
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
|
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
|
||||||
|
|
||||||
# Remove escapes (introduced by 'dialog' if options have parentheses).
|
# Remove escapes (introduced by 'dialog' if options have parentheses).
|
||||||
RETURN_ARRAY[i]=$(echo "${RETURN_ARRAY[i]}" | sed 's/\\//g')
|
RETURN_ARRAY[i]=${RETURN_ARRAY[i]//\\/} # ${variable//search/replace}
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
14
installer.sh
14
installer.sh
@ -1066,6 +1066,7 @@ function waConfigureApps() {
|
|||||||
|
|
||||||
# Sort the 'APPS' array in alphabetical order.
|
# Sort the 'APPS' array in alphabetical order.
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
|
# shellcheck disable=SC2207 # Silence warnings regarding preferred use of 'mapfile' or 'read -a'.
|
||||||
TEMP_ARRAY=($(sort <<<"${APPS[*]}"))
|
TEMP_ARRAY=($(sort <<<"${APPS[*]}"))
|
||||||
unset IFS
|
unset IFS
|
||||||
APPS=("${TEMP_ARRAY[@]}")
|
APPS=("${TEMP_ARRAY[@]}")
|
||||||
@ -1142,7 +1143,7 @@ function waConfigureDetectedApps() {
|
|||||||
EXE_FILENAME_NOEXT="${EXE_FILENAME%.*}"
|
EXE_FILENAME_NOEXT="${EXE_FILENAME%.*}"
|
||||||
|
|
||||||
# Check if the executable was previously configured as part of setting up officially supported applications.
|
# Check if the executable was previously configured as part of setting up officially supported applications.
|
||||||
if [[ ! " ${INSTALLED_EXES[@]} " =~ " ${EXE_FILENAME_LOWERCASE} " ]]; then
|
if [[ ! " ${INSTALLED_EXES[*]} " == *" ${EXE_FILENAME_LOWERCASE} "* ]]; then
|
||||||
# If not previously configured, add the application to the list of detected applications.
|
# If not previously configured, add the application to the list of detected applications.
|
||||||
APPS+=("${NAMES[$INDEX]} (${EXE_FILENAME_NOEXT})")
|
APPS+=("${NAMES[$INDEX]} (${EXE_FILENAME_NOEXT})")
|
||||||
fi
|
fi
|
||||||
@ -1150,6 +1151,7 @@ function waConfigureDetectedApps() {
|
|||||||
|
|
||||||
# Sort the 'APPS' array in alphabetical order.
|
# Sort the 'APPS' array in alphabetical order.
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
|
# shellcheck disable=SC2207 # Silence warnings regarding preferred use of 'mapfile' or 'read -a'.
|
||||||
TEMP_ARRAY=($(sort <<<"${APPS[*]}"))
|
TEMP_ARRAY=($(sort <<<"${APPS[*]}"))
|
||||||
unset IFS
|
unset IFS
|
||||||
APPS=("${TEMP_ARRAY[@]}")
|
APPS=("${TEMP_ARRAY[@]}")
|
||||||
@ -1321,11 +1323,14 @@ function waUninstall() {
|
|||||||
# Extract the file name.
|
# Extract the file name.
|
||||||
DESKTOP_FILE_NAME=$(basename "$DESKTOP_FILE_PATH" | sed 's/\.[^.]*$//')
|
DESKTOP_FILE_NAME=$(basename "$DESKTOP_FILE_PATH" | sed 's/\.[^.]*$//')
|
||||||
|
|
||||||
|
# Print feedback.
|
||||||
|
echo -n "Removing '.desktop' file for '${DESKTOP_FILE_NAME}'... "
|
||||||
|
|
||||||
# Delete the file.
|
# Delete the file.
|
||||||
$SUDO rm "$DESKTOP_FILE_PATH"
|
$SUDO rm "$DESKTOP_FILE_PATH"
|
||||||
|
|
||||||
# Print feedback.
|
# Print feedback.
|
||||||
echo "Removed '.desktop' file for '${DESKTOP_FILE_NAME}'."
|
echo -e "${DONE_TEXT}Done!${CLEAR_TEXT}"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Store the paths of bash scripts calling 'WinApps' to launch specific applications in an array, returning an empty array if no such files exist.
|
# Store the paths of bash scripts calling 'WinApps' to launch specific applications in an array, returning an empty array if no such files exist.
|
||||||
@ -1339,11 +1344,14 @@ function waUninstall() {
|
|||||||
# Extract the file name.
|
# Extract the file name.
|
||||||
BASH_SCRIPT_NAME=$(basename "$BASH_SCRIPT_PATH" | sed 's/\.[^.]*$//')
|
BASH_SCRIPT_NAME=$(basename "$BASH_SCRIPT_PATH" | sed 's/\.[^.]*$//')
|
||||||
|
|
||||||
|
# Print feedback.
|
||||||
|
echo -n "Removing bash script for '${BASH_SCRIPT_NAME}'... "
|
||||||
|
|
||||||
# Delete the file.
|
# Delete the file.
|
||||||
$SUDO rm "$BASH_SCRIPT_PATH"
|
$SUDO rm "$BASH_SCRIPT_PATH"
|
||||||
|
|
||||||
# Print feedback.
|
# Print feedback.
|
||||||
echo "Removed bash script for '${BASH_SCRIPT_NAME}'."
|
echo -e "${DONE_TEXT}Done!${CLEAR_TEXT}"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Print caveats.
|
# Print caveats.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user