The following is a piece of content my bash script will write into the nginx configuration file.
WEBAPP=example.com
APPFOLDER=abcapp
CONFFILENAME=abc.conf
read -r -d '' FILECONTENT <<'ENDFILECONTENT'
server {
listen 80;
client_max_body_size 2M;
server_name $WEBAPP;
root /var/virtual/stage.$WEBAPP/current/src/$APPFOLDER/webroot;
}
ENDFILECONTENT
echo "$FILECONTENT" > /etc/nginx/sites-available/$CONFFILENAME
The code works successfully to write the content inside /etc/nginx/sites-available/abc.conf.
However, I have two bash variables in $WEBAPP and $APPFOLDER. They are manifested exactly like that inside the file instead of example.com and abcapp which is what I intended.
How do I make the script work as intended?
readexists. It is rarely necessary and often misused.