I have a shell script:
TOPDIR=`pwd`
FOLDER=$($TOPDIR | sed 's/\//\_/g')
if [[ condition ]];then
source ~/[$FOLDER]-build/build-env.sh
fi
the TOPDIR
here is /home/uname/project
, so the variable FOLDER
is supposed to be _home_uname_project
because sed
is called to replace /
with _
.
But it goes wrong when executing, terminal tells that /home/uname/[]-build/build-env.sh: No such file or directory
which, I guess, means that FOLDER
is unexpected empty in the if-then statement. Can anybody help me with figuring this out?