diff --git a/games/factorio_development.sh b/games/factorio_development.sh index c18cd99a79f22e70e988abd2e7a550a894d9681f..3424e9ef5d8f4897366762594b035b83950f1ca7 100755 --- a/games/factorio_development.sh +++ b/games/factorio_development.sh @@ -421,7 +421,7 @@ function command_build() { return 1 fi - # Do some basic validation so we don't overwrite things by mistake. + # Do some basic validation so we do not overwrite things by mistake. if [[ -e $archive_file ]]; then error "Output archive already exists: $archive_file" return 1 @@ -435,12 +435,11 @@ function command_build() { mkdir -p "$dist_dir" # Copy the files. - if ! cd "$base_dir/"; then - error "Failed to switch to base directory: $base_dir" - return 1 - fi for mod_file in "${mod_files[@]}"; do - install -m 0644 -D "$mod_file" "${target_dir}/${mod_file%%${source_dir}/}" + if ! (cd "$base_dir" && install -m 0644 -D "$mod_file" "${target_dir}/${mod_file%%${source_dir}/}"); then + error "Failed to copy the file: $mod_file" + return 1 + fi done # Move sources to base directory. @@ -453,11 +452,7 @@ function command_build() { fi # Zip the files. - if ! cd "$build_dir/"; then - error "Failed to switch to build directory: $build_dir" - return 1 - fi - if ! zip -q -r "$archive_file" "$(basename "$target_dir")"; then + if ! (cd "$build_dir/" && zip -q -r "$archive_file" "$(basename "$target_dir")"); then error "Could not prepare the release archive." return 1 fi