Sujet : Re: Default PATH setting - reduce to something more sensible?
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.unix.shellDate : 23. Jan 2025, 22:59:37
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20250123134647.436@kylheku.com>
References : 1 2 3 4 5
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2025-01-23, Kenny McCormack <
gazelle@shell.xmission.com> wrote:
In article <ccr96l-eot.ln1@ID-313840.user.individual.net>,
Geoff Clare <netnews@gclare.org.uk> wrote:
...
Yes. Perhaps I trimmed too much. The post I was replying to said
"$HOME/bin [..] is better than ~/bin, because tilde expansion is not,
AFAIK, included in POSIX" and $HOME is also, of course, expanded before
PATH is assigned. So there is no reason to prefer $HOME/bin over ~/bin
since (when used in an assignment) they are equivalent in POSIX.
>
1) I have no idea what your beef with Kaz is. It seems silly at best.
Beef? I don't perceive any beef. If anything, Geoff seems to be setting
an example for me to be less of an asshole. :)
At this stage and age, it's unlikely to work, but you never know.
I know that I had lines in .profile
and/or .bashrc like: PATH=~/bin:$PATH (and similar) that did not work (that
is, the value stored in the variable contained an explicit tilde rather
than the expanded value - and this, of course, doesn't work at runtime).
Replacing the tilde with $HOME fixes this.
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.
By the way, the fact of tilde expansion not happening in double
quotes is a strikes against the Bash ~N feature for
referring to directories in the directory stack (pushd, popd).
My "cdlog" module, consisting entirely of shell scriptology outside of
the Bash executable, is far better.
In "cdlog" we refer to the third directory in the log (for instance)
as $c3. Additionally, the first four entries $c1 to $c4 are
also available as $x, $y, $z and $w: same number of keystrokes
as ~1 ... ~4.
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca