@@ -28,7 +28,8 @@ function backup_original_env_vars() {
2828
2929 # Backup original value if not already backed up
3030 if [[ -z " ${! backup_var} " ]] && [[ -n " ${! common_var} " ]]; then
31- eval " ${backup_var} =\" ${! common_var} \" "
31+ # Use printf -v to avoid eval and preserve quotes verbatim
32+ printf -v " $backup_var " ' %s' " ${! common_var} "
3233 echo " Backed up original ${common_var} =${! common_var} to ${backup_var} "
3334 fi
3435 done
@@ -43,11 +44,11 @@ function restore_original_env_vars() {
4344
4445 # Restore original value if backup exists
4546 if [[ -n " ${! backup_var} " ]]; then
46- eval " ${ common_var} = \" ${! backup_var} \" "
47+ printf -v " $ common_var" ' %s ' " ${! backup_var} "
4748 echo " Restored original ${backup_var} =${! backup_var} to ${common_var} "
4849 else
4950 # Clear the variable if no backup exists
50- eval " ${ common_var} = \"\ ""
51+ printf -v " $ common_var" ' %s ' " "
5152 echo " Cleared ${common_var} (no original backup)"
5253 fi
5354 done
@@ -64,12 +65,12 @@ function assign_browser_specific_env_vars() {
6465
6566 # Check if the browser-specific environment variable exists
6667 if [[ -n " ${! browser_specific_var} " ]]; then
67- # Assign the browser-specific value to the common variable
68- eval " ${ common_var} = \" ${! browser_specific_var} \" "
68+ # Assign the browser-specific value to the common variable, preserving quotes
69+ printf -v " $ common_var" ' %s ' " ${! browser_specific_var} "
6970 echo " Assigned ${browser_specific_var} =${! browser_specific_var} to ${common_var} "
7071 elif [[ -n " ${! backup_var} " ]]; then
7172 # Inherit original value if browser-specific value is not set
72- eval " ${ common_var} = \" ${! backup_var} \" "
73+ printf -v " $ common_var" ' %s ' " ${! backup_var} "
7374 echo " Inherited original ${backup_var} =${! backup_var} to ${common_var} "
7475 fi
7576 done
@@ -178,6 +179,10 @@ if [ -d "/opt/selenium/browsers" ]; then
178179 echo " [[node.driver-configuration]]" >> " $FILENAME "
179180 echo " display-name = \" ${SE_NODE_BROWSER_NAME} \" " >> " $FILENAME "
180181 echo " stereotype = '${SE_NODE_STEREOTYPE} '" >> " $FILENAME "
182+ # Validate SE_NODE_MAX_SESSIONS is a positive integer
183+ if [[ " ${SE_NODE_MAX_SESSIONS} " =~ ^[0-9]+$ ]] && [[ " ${SE_NODE_MAX_SESSIONS} " -gt 0 ]]; then
184+ echo " max-sessions = ${SE_NODE_MAX_SESSIONS} " >> " $FILENAME "
185+ fi
181186 echo " " >> " $FILENAME "
182187 fi
183188
0 commit comments