0

I created a file nano ~/uncwe/configurations/variables.sh. This file contains:

set -a
rse="~/${repo}/internal_software/rse.sh"
set +a

I sourced the file, then tried to execute:

${rse}
bash ${rse} 

Both output No such file or directory, although, echo ${rse} returns:

~/uncwe/internal_software/rse.sh

That's odd to me, because that file ~/uncwe/internal_software/rse.sh is alive and kicking, and I can run it directly by:

~/uncwe/internal_software/rse.sh

In this case, the file runs just fine.

Hence I'd like to ask why is the file's execution fail when done by expanding the variable that contains its path as in both ways shown above?

It is important to me to run this file from expanding the variable (and not use an alias) because I need to run that script inside scripts (and aliases aren't good for that in the current release of Bash).

  • 3
    As an added comment: Use $HOME in shell scripts instead of tilde. It behaves as a variable (tilde does not), and is more "self documenting" than tilde. – Kusalananda Feb 12 '18 at 20:20
  • Thanks. I thought of adding ~="${HOME}" to ~/.bashrc; Sadly, it didn't work. Meh, I'll get used to the environment variable ${HOME} instead ~ as a value of a variable. – Arcticooling Feb 12 '18 at 21:23

0 Answers0