1

I have the following bash script snippet that switches to the node user and uses heredoc syntax to run a series of commands which is required. How can I share the variable $APP_VERSION into the node user? Currently $APP_VERSION is showing undefined when printed. I thought exporting it would work, but seems not.

#!/usr/bin/env bash
set -eo pipefail; [[ $TRACE ]] && set -x

export APP_VERSION=1.4.5

sudo su node <<'EOF'
   printf "APP VERSION IS: %s" "$APP_VERSION"
   node app.$APP_VERSION.js
EOF
Justin
  • 42,716
  • 77
  • 201
  • 296

0 Answers0