0

How can I expand APP_VERSION so that it gets used in the rest of my script? As it is right now, it doesn't expand and show the argument I pass in via the CLI.

APP_VERSION=$2

BOOTSTRAP_RUN='[{"Path":"s3://abc/scripts/emr/deploy_zip.sh ${APP_VERSION}","Name":"Custom action"}]'
sdot257
  • 10,046
  • 26
  • 88
  • 122
  • 1
    The kind of quotes matter -- *single quotes* prevent expansion. – Charles Duffy Jan 22 '18 at 18:00
  • That said, you shouldn't use simple string substitution when generating JSON. – Charles Duffy Jan 22 '18 at 18:00
  • 1
    `jq` will ensure that contents are correctly quoted and escaped: `bootstrap_run=$(jq -nc --arg path "s3://abc/scripts/emr/deploy_zip.sh $2" '[{"Path": $path, "Name": "Custom action"}]')` – Charles Duffy Jan 22 '18 at 18:09
  • 1
    (note the use of lower-case variables; see http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html, fourth paragraph -- convention is for all-caps names to be used for environment and shell variables with meaning to POSIX-specified utilities, whereas lowercase names are reserved for application use). – Charles Duffy Jan 22 '18 at 18:10

0 Answers0