Deutsch English Français Italiano |
<87ed0qba54.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 18:07:35 -0800 Organization: None to speak of Lines: 69 Message-ID: <87ed0qba54.fsf@nosuchdomain.example.com> References: <vm5dei$2c7to$1@dont-email.me> <vmthmu$3bb88$1@news.xmission.com> <vmtrqk$92b$1@reader2.panix.com> <vmu94j$1q2lp$1@dont-email.me> <vn05ji$r20$1@reader2.panix.com> <vn0bpf$29qe6$1@dont-email.me> <871pwr6fe9.fsf@nosuchdomain.example.com> <vn2ier$2phv1$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Sun, 26 Jan 2025 03:07:36 +0100 (CET) Injection-Info: dont-email.me; posting-host="fe08763d6b1c9b85d57c56913c7d5466"; logging-data="3390554"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18fbR9GlZMnWO+03cRZejhN" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:r2CC3gA+IIj/VCcv8ITCJbOm6vI= sha1:CbxJj3dDyoEnwr6CDn+WoGCyrZc= Bytes: 3810 Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes: > On 24.01.2025 23:00, Keith Thompson wrote: >> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes: >>> On 24.01.2025 14:46, Dan Cross wrote: >> [...] >> >> /usr/bin/which is limited in what it can do. It follows POSIX-specified >> behavior for $PATH; it doesn't recognize any shell-specific rules. [...] > > Sure. > >> [...] >>> The settings PATH=~/bin and PATH="~/bin" respectively shall >>> result in the same behavior across shells when searching for >>> programs; in the first case looking into "/home/someuser/bin/" >>> and in the second case looking into "./~/bin/" (i.e. a path >>> component with a local directory named "~"). >> >> What do you mean by "shall result? > > I mean that a shell should behave consistently. (I think Bash does > not in the given case.) Consistently with what? Bash consistently expands literal '~'s in $PATH, and consistently disables that expansion in POSIX mode. All shells have shell-specific features. What's odd about this case is that bash has a POSIX-violating feature that affects command name resolution. If this particular feature were documented, I'd have less of a problem with it (but I'd still avoid using it). >> All shells that conform to POSIX behave as you describe. bash doesn't >> conform to POSIX unless you ask it to. Neither do csh, tcsh, and fish. I should have mentioned that csh, tcsh, and fish don't conform to POSIX at all. > We were speaking about shell programming, so [seriously] I don't > consider Csh and Tcsh as sensible sample shells for the discussion. > (Thinking about it, I wonder whether Bash inherited tilde-handling > from Csh, maybe; that would at least explain something.) No, csh and tcsh (at least in current versions) don't expand literal '~'s in $PATH. > (I don't know Fish, so I cannot comment on that.) Nor do I. I don't mind excluding non-Bournish shells like csh, tcsh, and fish from the discussion, but I like to mention now and then that they're being excluded. They are shells, after all. >> [...] > >> BTW, it hadn't occurred to me that you can have a relative path in a >> component of $PATH, but it does seem to work. I won't be taking >> advantage of this information. > > Yes. Some prefer to add '.' to PATH. (Though I have no intention > to discuss that habit.) Right, of course '.' is a relative path. I should have thought of that. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */