| Deutsch English Français Italiano |
|
<87msfebbkf.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: Sat, 25 Jan 2025 17:36:48 -0800
Organization: None to speak of
Lines: 49
Message-ID: <87msfebbkf.fsf@nosuchdomain.example.com>
References: <vm5dei$2c7to$1@dont-email.me> <vmu94j$1q2lp$1@dont-email.me>
<vn05ji$r20$1@reader2.panix.com> <vn0bpf$29qe6$1@dont-email.me>
<vn110t$faa$1@reader2.panix.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Date: Sun, 26 Jan 2025 02:36:53 +0100 (CET)
Injection-Info: dont-email.me; posting-host="fe08763d6b1c9b85d57c56913c7d5466";
logging-data="3390554"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19FYiZtuGyrK/n/3d0XPqBn"
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:6eSlV+faoMiag6vQc8PxiGoMfXw=
sha1:TYVP4+4aUNVIsk73jYlnIRGpgOQ=
Bytes: 3168
cross@spitfire.i.gajendra.net (Dan Cross) writes:
> In article <vn0bpf$29qe6$1@dont-email.me>,
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
[...]
>>if not a bug, looks like a Bad Design Idea if it's been done
>>deliberately. - YMMV.
>
> It's obviously being done deliberately, and is easy to find in
> the source code:
> https://git.savannah.gnu.org/cgit/bash.git/tree/findcmd.c#n533
The code in question is:
xpath = (posixly_correct == 0 && *path == '~') ? bash_tilde_expand (path, 0) : path;
where `path` is an element of $PATH.
This is obviously deliberate, and I see similar code (without the
posixly_correct condition) in bash 1.05 from 1990.
According to Wikipedia, POSIX began in 1988, and the initial
release of bash was in 1989, just a year later. Obviously the
authors thought that expanding literal '~'s in $PATH was a good
idea at the time, and it's not suprising that they didn't pay much
attention to POSIX. It would have been nice if they'd documented it.
> You may consider it bad design, and you're well within your
> rights to do so, but opinions on that vary, and it doesn't mean
> yours is correct.
As far as I can tell (I haven't investigated), all Bourne-based
shells other than Bash treat $PATH in the same way when executing
commands. Bash is the only shell I'm aware of that expands literal
'~' in $PATH.
The fact that it's not POSIX compliant behavior is at worst mildly
annoying. Bash correctly disables it in POSIX mode (enabled by the
--posix option, by running "set -o posix", by setting $POSIXLY_CORRECT
before starting bash, or by invoking it sas "sh").
I dislike the behavior because (a) it can quietly cause unexpected
problems (it's easy to miss the fact that $HOME is expanded within
double quotes and ~ is not), and (b) it's not documented. I certainly
consider it a misfeature. Whether it rises to the level of a bug is
a matter of opinion.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */