From f555a71f540169a6871bc489632130836e7bcb51 Mon Sep 17 00:00:00 2001 From: Robert Krikk Date: Thu, 12 Oct 2023 16:22:08 +0300 Subject: [PATCH] Improved algorithm --- entrypoint.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 5115058..4359911 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -116,13 +116,17 @@ main() { # Iterate over $INPUT_SOURCE multiline string and run aws s3 $COMMAND while IFS= read -r source; do - if [ "$COMMAND" == "cp" ] || [ "$COMMAND" == "mv" ] || [ "$COMMAND" == "sync" ] - then - echo "aws s3 $COMMAND \"$source\" $INPUT_DESTINATION $INPUT_FLAGS" - aws s3 "$COMMAND" "$source" "$INPUT_DESTINATION" "$INPUT_FLAGS" + if [ -n "$source" ]; then + if [ "$COMMAND" == "cp" ] || [ "$COMMAND" == "mv" ] || [ "$COMMAND" == "sync" ] + then + echo "aws s3 $COMMAND \"$source\" $INPUT_DESTINATION $INPUT_FLAGS" + aws s3 "$COMMAND" "$source" "$INPUT_DESTINATION" "$INPUT_FLAGS" + else + echo "aws s3 $COMMAND \"$source\" $INPUT_FLAGS" + aws s3 "$COMMAND" "$source" "$INPUT_FLAGS" + fi else - echo "aws s3 $COMMAND \"$source\" $INPUT_FLAGS" - aws s3 "$COMMAND" "$source" "$INPUT_FLAGS" + echo "Source is empty, skipping AWS S3 command." fi done <<< "$INPUT_SOURCE" }