Never use ~ in your $PATH (/bin/sh might not expand it)
dash
doesn’t exand ~
when it occurs in $PATH
, so if you want your scripts or environment to be portable across shells, you should never use ~
in your $PATH
.
/bin/sh
is dash
in Debian and in Ubuntu, so you’re most likely to encounter this problem when using the #!/bin/sh
shebang on those operating systems.
To demonstrate this behavior on by Debian Stretch machine, let’s create a helloworld
script in ~/
and take a look at our $PATH
:
bash
expands ~
when it occurs in $PATH
:
But dash
doesn’t: