benqzq
By:
benqzq

Variable substitution fails for exported variable

January 31, 2018 166 views
Linux Commands Ubuntu 16.04

While in my home directory, I ran export drt="/var/www/html". I then sourced a script (script 1) that in between other commands, also sources another script (script 2):

#!/bin/bash
find ${drt}/ -type f -iname "*phpmyadmin*" -exec rm -rf {} \;
wget -P ${drt}/ https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.zip

As you can see, the desired state is to download phpmyadmin to the value of drt, which is of course /var/www/html, but instead being downloaded to /var/www/html, it was downloaded to my home directory.

Not only I sourced every script, I exported the variable to have full scope possible just in case, but it seems not to be enough and the ${drt} variable substitution fails.

  • I tried to debug with set -x at the base of the script, but I got no enlighting output.
  • To source a file I use the command source myFile, not any other syntax.
Be the first one to answer this question.