Changeset - ad978ac39cbc
[Not reviewed]
0 1 0
Branko Majic (branko) - 4 years ago 2020-07-06 15:55:41
branko@majic.rs
Noticket: [factorio_manager.sh] Use quotes around right-hand sides of operators:

- Right-hand side is treated as glob, so quoting is necessary to avoid
errors. For example, if var='[a]', then [[ $a == $a ]] will always
be false.
1 file changed with 6 insertions and 6 deletions:
0 comments (0 inline, 0 general) First comment
games/factorio_manager.sh
Show inline comments
 
@@ -510,7 +510,7 @@ function validate_server_setting_value() {
 

	
 
        for i in "${possible_values[@]}"; do
 
            # Allow strings without quotes to be specified by the user.
 
            [[ $value == $i || \"$value\" == $i ]] && result=0
 
            [[ $value == "$i" || \"$value\" == "$i" ]] && result=0
 
        done
 

	
 
        [[ $result == 0 ]] || colorecho red "$name must be one of listed values [$type]."
 
@@ -866,7 +866,7 @@ function read_server_settings() {
 

	
 
            for i in "${possible_values[@]}"; do
 
                # Convenience for allowing strings without quotes specified by the user.
 
                [[ \"${settings_value[$key]}\" == $i ]] && settings_value[$key]="\"${settings_value[$key]}\""
 
                [[ \"${settings_value[$key]}\" == "$i" ]] && settings_value[$key]="\"${settings_value[$key]}\""
 
            done
 

	
 
        # List of strings.
 
@@ -1060,8 +1060,8 @@ function select_factorio_version() {
 
        echo -n "  [$i] $(basename "${game_versions_available[$i-1]}")"
 

	
 
        # Highlight default version.
 
        if [[ -z $default_version && $i == ${#game_versions_available[@]} ]] || \
 
               [[ -n $default_version && ${game_versions_available[i-1]} == $default_version ]]; then
 
        if [[ -z $default_version && $i == "${#game_versions_available[@]}" ]] || \
 
               [[ -n $default_version && ${game_versions_available[i-1]} == "$default_version" ]]; then
 
            colorecho boldgreen " [$default_marker]"
 
            default_option="$i"
 
        else
 
@@ -1386,7 +1386,7 @@ elif [[ $command == launch ]]; then
 
    current_write_data=$(grep "^write-data=" "$game_config")
 
    expected_write_data="write-data=${instance_directory}"
 

	
 
    if [[ $current_write_data != $expected_write_data ]]; then
 
    if [[ $current_write_data != "$expected_write_data" ]]; then
 
        warning "Incorrect path specified for write-data in game configuration file: $game_config"
 
        warning "Current configuration is: $current_write_data"
 
        warning "Configuration will be replaced with: $expected_write_data"
 
@@ -1758,7 +1758,7 @@ elif [[ $command == set-version ]]; then
 
    echo
 

	
 
    # Change instance game version.
 
    if [[ $game_version_selected == $game_version ]]; then
 
    if [[ $game_version_selected == "$game_version" ]]; then
 
        info "Current version has been kept."
 
    else
 
        sed -i -e "s/^game_version=.*/game_version=$game_version_selected/" "$instance_config"
0 comments (0 inline, 0 general) First comment
You need to be logged in to comment. Login now