Home > Software design >  Using variable to declare parameters [Shell]
Using variable to declare parameters [Shell]

Time:07-18

I have a shell script that runs the command "aws s3 sync".

As there are some IFs in the middle of this script, I change the value of the flags as needed.

However, only the variable $flagIgnore is not being considered in the "aws s3 sync".
The $flag_delete variable works.

See an example of what I'm doing

#!/bin/bash
##################################
localFolder='/test1/'
remoteFolder='/test1/'
flagDelete="--delete"
flagIgnore="--exclude 'node_modules/' --exclude 'sass/' --exclude '*.DS_Store' --exclude '*.ini' --exclude '*.json' --exclude '*.log' --exclude '.babelrc' --exclude '.eslintrc*' --exclude 'gulpfile.js'"

aws s3 sync --dryrun $flagDelete --size-only --cache-control max-age=2592000 $flagIgnore "$localFolder" "$remoteFolder"

CodePudding user response:

Can you try flagIgnore='--exclude node_modules/ --exclude sass/ --exclude *.DS_Store --exclude *.ini --exclude *.json --exclude .log --exclude .babelrc --exclude .eslintrc --exclude gulpfile.js'

  • Related