I'm attempting to write a bash script named updateFile.sh. It's currently as follows:
function insertIntoFile(){
local variable=$1
local target=$2
echo "${variable}" | tee -a "${target}";
}
insertIntoFile "export/ foo=bar" "~/.bash_profile"
Running bash -x ./updateFile.sh
For output, I get...
...
+ echo 'export/ foo=bar'
+ tee -a '~/.bash_profile'
export/ foo=bar
however, when I cat ~/.bash_profile
It's still empty of the given string.
I've tried the export without the slash, so I know that's not it, and I've dug through stack overflow, and everything I've seen seems to indicate that this should work, yet I don't see why it's not or how to fix it.