0

I want to fetch some environment variable which are set in .bash_aliases file. I want use them in my bash script

#!/bin/dash
echo $PATH
echo $DEPOT_TOOLS

Both are coming empty string once call it in myscript. In the terminal these variable are printing successfully.

Matt
  • 14,906
  • 27
  • 99
  • 149
dead programmer
  • 4,223
  • 9
  • 46
  • 77

1 Answers1

0

All you have to do is source the .bash_aliases file -- however as dash does only supports POSIX shell syntax you'll likely find that there are definitions inside of .bash_aliases that don't work for dash. If this is the case simply put your aliases inside of a different file and source that. Also the environment variable PATH is generally always available not sure what's going on with your system.

#!/bin/dash
. .some_aliases
echo "$PATH"
echo "$something_else"