Changeset - 9bf3870befd3
[Not reviewed]
0 1 0
Branko Majic (branko) - 4 years ago 2020-07-06 17:07:18
branko@majic.rs
Noticket: [factorio_manager.sh] Disable a couple of false positives from shellcheck, and do not use $? when checking flock's exit code.
1 file changed with 6 insertions and 2 deletions:
0 comments (0 inline, 0 general) First comment
games/factorio_manager.sh
Show inline comments
 
@@ -403,12 +403,15 @@ function colorprintf() {
 
    local reset="$_text_reset"
 

	
 
    local color="$1"
 
    local format="$2"
 
    shift 2
 

	
 
    # Variables within this printf are used for dynamic color and
 
    # formatting, and can't be used as arguments.
 
    # shellcheck disable=SC2059
 
    printf "${_text_colors[$color]}${format}${reset}" "$@"
 
}
 

	
 
#
 
# Presents user with a warning, asks user for confirmation to
 
# continue, and terminates the script is confirmation is not provided
 
@@ -1142,14 +1145,13 @@ function lock() {
 
    local fd="$2"
 

	
 
    lock_files+=("$lock_file")
 

	
 
    # Obtain lock - Factorio uses the same mechanism, so we should
 
    # be able to detect the game is running in this way.
 
    flock --exclusive --nonblock "$fd"
 
    if [[ $? != 0 ]]; then
 
    if ! flock --exclusive --nonblock "$fd"; then
 
        error "Could not acquire lock via lock file '$lock_file'. Is Factorio still running?"
 
        exit "$ERROR_GENERAL"
 
    fi
 
}
 

	
 
# Define error codes.
 
@@ -1277,12 +1279,13 @@ elif [[ $command == list ]]; then
 

	
 
    # Find all sub-directories that are valid instances.
 
    for candidate in "$manager_directory"/*; do
 
        if [[ -f $candidate/instance.conf ]]; then
 
            # shellcheck source=/dev/null
 
            source "$candidate/instance.conf"
 
            # shellcheck disable=SC2154 # game_version is read from the configuration file
 
            echo "  - $(basename "$candidate") ($game_version)"
 
        fi
 
    done
 
    echo
 

	
 

	
 
@@ -1880,12 +1883,13 @@ elif [[ $command == info ]]; then
 

	
 
        # Query string used in jq tool to determine if mod is enabled
 
        # or not. Take note that this string should remain
 
        # single-quoted, and that $ expansions are actually done
 
        # internally in jq itself. Query accepts two vars - mod_name
 
        # and enable_new_mods.
 
        # shellcheck disable=SC2016 # The $enable_new_mods is meant to be interpreted by jq, not bash.
 
        jq_is_enabled_query='.mods | map(select(.name==$mod_name))[0] // {"name": "default", "enabled": $enable_new_mods} | .enabled'
 

	
 
        # Process every mod found.
 
        for mod_file in "${mod_files[@]}"; do
 

	
 
            if [[ -f $mod_file ]]; then
0 comments (0 inline, 0 general) First comment
You need to be logged in to comment. Login now