From 5d8f4266050d41fdce1497dd6805cabf14cb9cfd 2020-07-05 00:46:49 From: Branko Majic <branko@majic.rs> Date: 2020-07-05 00:46:49 Subject: [PATCH] Noticket: Clean-up set-game-dir command in Factorio Manager: - Small refactoring and fixing of variable names and outputs. --- diff --git a/games/factorio_manager.sh b/games/factorio_manager.sh index 2c8d3ab8bbfbca3b0a6fde334247e12c1bf8fec6..d96d9efb0d0aa092e064aab8dabb5367e740a2e5 100755 --- a/games/factorio_manager.sh +++ b/games/factorio_manager.sh @@ -875,43 +875,40 @@ shift if [[ $command == set-game-dir ]]; then # Read and verify additional positional arguments. - game_installations_directory="${1-}" + game_installations_directory_target="${1-}" shift - if [[ -z $game_installations_directory ]]; then + if [[ -z $game_installations_directory_target ]]; then error "Missing argument: GAME_INSTALLATIONS_DIRECTORY" exit "$ERROR_ARGUMENTS" fi - if [[ ! -e $game_installations_directory ]]; then + if [[ ! -e $game_installations_directory_target ]]; then error "No such directory: $game_installations_directory" exit "$ERROR_GENERAL" fi - # Set-up additional derived variables. - symlink="$manager_directory/.game_installations" - # Verify that at least one Factorio instance can be found. factorio_versions_found=0 - for candidate in "$game_installations_directory"/*; do + for candidate in "$game_installations_directory_target"/*; do if [[ -f $candidate/bin/x64/factorio ]]; then let factorio_versions_found++ fi done if (( $factorio_versions_found == 0 )); then - error "Could not locate any Factorio installations under: $game_installations_directory" + error "Could not locate any Factorio installations under: $game_installations_directory_target" exit "$ERROR_GENERAL" fi # Update the link - if [[ -L $symlink ]]; then - rm "$symlink" + if [[ -L $game_installations_directory ]]; then + rm "$game_installations_directory" fi - if ! ln -s "$game_installations_directory" "$symlink"; then - error "Could not create symlink from $game_installations_directory to $symlink." + if ! ln -s "$game_installations_directory_target" "$game_installations_directory"; then + error "Could not create symlink from '$game_installations_directory_target' to '$game_installations_directory'." exit "$ERROR_GENERAL" fi