Following this answer in superuser, I have wrote that function in bash:
_add_env()
{
export $1
if [[ ":\$$1:" != *":$2:"* ]]; then
eval $1="\$$1:$2";
fi
};
I'm calling it that way: _merge_env PATH "/home/subway/land"
It seems that the condition is true even though PATH contains the given path.
Here is the relevant bash -x output:
- 579 :[[ :$PATH: != :/\h\o\m\e/\s\u\b\w\a\y/\l\a\n\d: ]]
- 580 :eval 'PATH=$PATH:/home/subway/land'
What am I doing wrong?