Code to hopefully avoid existing entries.

This commit is contained in:
Storm Dragon 2023-12-13 21:53:22 -05:00
parent 194aa901bf
commit f99d620b21

12
tojam
View File

@ -48,9 +48,19 @@ add_server() {
valid="false"
fi
if ! [[ "${serverInfo[2]}" =~ ^[1-9][0-9]*$ ]]; then
errorMessage+="Port must be numeric."
errorMessage+="Port must be numeric.\n"
valid="false"
fi
for i in "${!servers[@]}" ; do
if [[ "$i" == "${serverInfo[0]}" ]]; then
errorMessage+="Server name \"$i\" is already in use.\n"
valid="false"
fi
if [[ "${servers[${i}]}" == "${serverInfo[1]}" ]]; then
errorMessage+="Server address \"$i\" is already added.\n"
valid="false"
fi
done
if [[ "${valid}" == "false" ]]; then
dialog --backtitle "Tojam" \
--msgbox "${errorMessage}" -1 -1