Deutsch   English   Français   Italiano  
<20250123134647.436@kylheku.com>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: Kaz Kylheku <643-408-1753@kylheku.com>
Newsgroups: comp.unix.shell
Subject: Re: Default PATH setting - reduce to something more sensible?
Date: Thu, 23 Jan 2025 21:59:37 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <20250123134647.436@kylheku.com>
References: <vm5dei$2c7to$1@dont-email.me>
 <1a876l-53v.ln1@ID-313840.user.individual.net>
 <20250122120930.74@kylheku.com>
 <ccr96l-eot.ln1@ID-313840.user.individual.net>
 <vmthmu$3bb88$1@news.xmission.com>
Injection-Date: Thu, 23 Jan 2025 22:59:37 +0100 (CET)
Injection-Info: dont-email.me; posting-host="6ac8c3413732086a36d6350b8929b58e";
	logging-data="1929295"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18r+NsCifdt7RCo6/AViXgiPXh1FITsWQg="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:g6iB4Yq4CR7ra8hwUig/jSp+Hi0=
Bytes: 3162

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/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca