diff --git a/entrypoint.sh b/entrypoint.sh index 4359911..843396a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -115,20 +115,27 @@ main() { aws --version # Iterate over $INPUT_SOURCE multiline string and run aws s3 $COMMAND - while IFS= read -r source; do +while IFS= read -r source; do 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" + if [ "$COMMAND" == "cp" ] || [ "$COMMAND" == "mv" ] || [ "$COMMAND" == "sync" ]; then + if [ -n "$INPUT_FLAGS" ]; then + cmd="aws s3 $COMMAND \"$source\" $INPUT_DESTINATION $INPUT_FLAGS" + echo "Executing command: $cmd" + $cmd + else + cmd="aws s3 $COMMAND \"$source\" $INPUT_DESTINATION" + echo "Executing command: $cmd" + $cmd + fi else - echo "aws s3 $COMMAND \"$source\" $INPUT_FLAGS" - aws s3 "$COMMAND" "$source" "$INPUT_FLAGS" + cmd="aws s3 $COMMAND \"$source\" $INPUT_FLAGS" + echo "Executing command: $cmd" + $cmd fi else echo "Source is empty, skipping AWS S3 command." fi - done <<< "$INPUT_SOURCE" +done <<< "$INPUT_SOURCE" } main