From 632ce7f506898b3d560423abda040ee6eb5f7062 Mon Sep 17 00:00:00 2001 From: the-sane <3657071+the-sane@users.noreply.github.com> Date: Mon, 7 Sep 2020 20:36:26 -0400 Subject: [PATCH] Sanity check message function arguments --- lug-helper.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lug-helper.sh b/lug-helper.sh index f87f3f1..1f5ac42 100755 --- a/lug-helper.sh +++ b/lug-helper.sh @@ -50,8 +50,15 @@ conf_subdir="starcitizen-lug" # To call this function, use the following format: message [type] "[string]" # See the message types below for instructions on formatting the string. message() { + # Sanity check + if [ "$#" -lt 2 ]; then + echo -e "\nScript error: The message function expects two arguments. Aborting." + read -n 1 -s -p "Press any key..." + exit 0 + fi + + # Use zenity messages if available if [ "$has_zen" -eq 1 ]; then - # Use zenity messages if available case "$1" in "info") # info message @@ -69,7 +76,7 @@ message() { margs=("--question" "--text=") ;; *) - echo -e "\nInvalid message type passed to the message function. Aborting." + echo -e "\nScript Error: Invalid message type passed to the message function. Aborting." read -n 1 -s -p "Press any key..." exit 0 ;; @@ -116,7 +123,7 @@ message() { done ;; *) - echo -e "\nInvalid message type passed to the message function. Aborting." + echo -e "\nScript Error: Invalid message type passed to the message function. Aborting." read -n 1 -s -p "Press any key..." exit 0 ;;