Changeset - 44094e9d54b7
[Not reviewed]
0 1 0
Branko Majic (branko) - 2 years ago 2022-08-21 13:41:24
branko@majic.rs
[factorio_development.sh] Avoid switching directories within commands:

- Should make commands easily callable from within other commands.
- Avoid using the single quotes (don't -> do not) so Emacs syntax
highlighter/formatter would not get confused.
1 file changed with 6 insertions and 11 deletions:
0 comments (0 inline, 0 general) First comment
games/factorio_development.sh
Show inline comments
 
@@ -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
0 comments (0 inline, 0 general) First comment
You need to be logged in to comment. Login now