Deutsch   English   Français   Italiano  
<87ldv06axs.fsf@nosuchdomain.example.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: Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups: comp.unix.shell
Subject: Re: Default PATH setting - reduce to something more sensible?
Date: Thu, 23 Jan 2025 21:24:47 -0800
Organization: None to speak of
Lines: 77
Message-ID: <87ldv06axs.fsf@nosuchdomain.example.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> <20250123134647.436@kylheku.com>
	<87v7u5m9m5.fsf@nosuchdomain.example.com>
	<87y0z1595p.fsf@nosuchdomain.example.com>
	<20250123171808.91@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Fri, 24 Jan 2025 06:24:48 +0100 (CET)
Injection-Info: dont-email.me; posting-host="ce3eaee7b38cea081e4acffc0808b70e";
	logging-data="2192399"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+bLHKiCHrcah+wHu6qpGkx"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:7N1gOzcIp2uGMk3yTWsmLuozA1Y=
	sha1:mx6qZCzhfS1X4vunk/3C5tQ4zs8=
Bytes: 4081

Kaz Kylheku <643-408-1753@kylheku.com> writes:
> On 2025-01-24, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>> Here's my bug report:
>>
>> https://lists.gnu.org/archive/html/bug-bash/2025-01/msg00114.html
>
> The documentation's wording that is second most relevant to this
> issue is:
>
>   "Each variable assignment is checked for unquoted tilde-prefixes
>   immediately following a ':' or the first '='. In these cases, tilde
>   expansion is also performed.  Consequently, one may use filenames with
>   tildes in assignments to PATH, MAILPATH, and CDPATH, and the shell
>   assigns the expanded value."
>
> In particular, the "Consequently," suggests that it is /as a
> consequence/ of the above requirements (expansion of unescaped tildes in
> variable assignments), and no other requirements, that it is possible to
> tildes in PATH!

That merely means that you can write something like

    PATH=/usr/local/bin:~/bin:/usr/bin:/bin

and the ~ is expanded to $HOME when the assignment is performed.
I don't see any implication about ~ being expanded when $PATH is
queried when running a command.

    $ PATH=/usr/local/bin:~/bin:/usr/bin:/bin
    $ echo "$PATH"
    /usr/local/bin:/home/kst/bin:/usr/bin:/bin
    $ PATH="/usr/local/bin:~/bin:/usr/bin:/bin"
    $ echo "$PATH"
    /usr/local/bin:~/bin:/usr/bin:/bin

> I say second most relevant, because I the most relevant passage in
> the GNU Info manual:
>
>   6.11 Bash POSIX Mode
>
>   [ ... ]
>
>   The following list is what's changed when 'POSIX mode' is in effect:
>
>   1. [ ... ]
>
>   [ ... ]
>
>   19. Literal tildes that appear as the first character in elements of
>   the PATH variable are not expanded as described above under
>   Tilde Expansion.
>
> Aha! This is the very feature: leading literal tildes in the PATH
> elements being expanded, disabled by POSIX mode (such as invocation
> as #!/bin/sh).
>
> But Tilde Expansion mentions no such thing!

Exactly.

> That's where the documentation would have to be, to fix the
> dangling reference above.
>
> Still, the requirement itself can be deemed as being documented by point
> 19 above; it implies that when Bash is in POSIX mode, tildes are somehow
> expanded. Though the promised detailed description is missing, it
> cannot reasonably be anything other than replacement by $HOME,
> which is the actual behavior that can be inferred from experiments.

I suggested in my bug report that this feature can cause problems.
You can set $PATH to a value that's treated as intended for commands
executed from the bash prompt, but not for commands invoked by
other commands.

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */