refactor of server_set_property(), move content of if block into the case statement and check if path is already absolute.

This commit is contained in:
Tristan Donkers 2015-08-28 23:25:28 +10:00
parent 0a637b82b7
commit af13191bb2

View File

@ -1714,15 +1714,15 @@ server_connected() {
# $2: The name of the server property
# $3: The value for the property
server_set_property() {
# If it is a path make that path absolute
if [[ "$2" =~ _PATH$ ]]; then
server_property "$1" PATH
eval SERVER_$2[$1]=\"${SERVER_PATH[$1]}/$3\"
else
eval SERVER_$2[$1]=\"$3\"
fi
eval SERVER_$2[$1]=\"$3\"
### Changes to values before setting
case "$2" in
*_PATH)
server_property "$1" PATH
if [[ ! "$3" =~ ^${SERVER_PATH[$1]} ]]; then
eval SERVER_$2[$1]=\"${SERVER_PATH[$1]}/$3\"
fi
;;
SCREEN_NAME)
eval SERVER_$2[$1]=\"${SERVER_SCREEN_NAME[$1]//\{SERVER_NAME\}/${SERVER_NAME[$1]}}\"
;;