Sujet : Re: Default PATH setting - reduce to something more sensible?
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.unix.shellDate : 23. Jan 2025, 23:46:42
Autres entêtes
Organisation : None to speak of
Message-ID : <87v7u5m9m5.fsf@nosuchdomain.example.com>
References : 1 2 3 4 5 6
User-Agent : Gnus/5.13 (Gnus v5.13)
Kaz Kylheku <
643-408-1753@kylheku.com> writes:
[...]
The obvious situation is double quotes. Inside double quotes, parameter
expansion happens, but not tilde expansion (not to mention pathname
expansion (globbing) and perhaps some other things).
>
So this won't work:
>
PATH="$PATH:~/bin"
>
Sorry I don't have details, but it is true nonetheless.
>
There they are.
[...]
In fact it probably will *partially* work. As I mentioned elsethread,
bash expands a leading ~ (or even ~username) in an element of $PATH when
executing a command.
But if you run a program from the command line that invokes another
program (say, a C program that calls system()), it won't treat that
element of $PATH the same way.
For this and other reasons, though you *can* have a literal ~ in $PATH
in bash, it's best to avoid it and use $HOME instead. A literal '$HOME'
won't work at all, but that's less likely to be a problem if your at all
aware of how double quotes work in the shell.
I suggest that bash's undocumented behavior is less than helpful.
I'll probably submit a bug report.
-- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.comvoid Void(void) { Void(); } /* The recursive call of the void */