Avoid using literal tilde in PATHSH-2147
Using literal ~
s in $PATH
is not recommended since such usage is only supported by bash
.
Even if the only shell you use is bash
, you should avoid such syntax because any invoked program that relies on $PATH
will effectively ignore such nonstandard entries.
For example, when make
is invoked with a $PATH
value containing ~
s, it may not be able to find the commands it is directed to execute even though the command is accessible in Bash and both programs make use of the same path, leave alone the possibility that Make may have been invoked from bash
. You'll get similar messages within any other shell, and any non-bash scripts will not work with such a $PATH
variable, and whereis foo
will come up empty.
It is recommended to use $HOME
or an absolute path instead.
Bad Practice
PATH="$PATH:~/bin"
Recommended:
PATH="$PATH:$HOME/bin"
Exceptions
Please ignore this issue if your directory name actually contains a literal tilde.