[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bash is incorrectly and inconsistently expanding tilde in $PATH

From: Chet Ramey
Subject: Re: Bash is incorrectly and inconsistently expanding tilde in $PATH
Date: Sat, 6 May 2017 16:48:54 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.0.1

On 5/3/17 6:40 PM, Nikolay Aleksandrovich Pavlov (ZyX) wrote:

> Bash Version: 4.3
> Patch Level: 48
> Release Status: release
> Description:
>       If $PATH in bash contains ~ (e.g. `PATH='~/bin'`) it is incorrectly 
> treated 
>       as if $HOME is present.

Yes. This is one of the oldest features in bash; it was present in the
first version of bash that performed tilde expansion. This was almost 30
years ago, but I believe part of the rationale was that the C library on
the GNU system would perform the same tilde expansion wherever it needed
to inspect $PATH (e.g., execlp and execvp).  For whatever reason, glibc
did not end up moving that feature forward.

I agree that it's not a great idea to have tildes in $PATH, but I doubt
this is a real problem.

Your contrived example demonstrates that while negative effects are
theoretically possible, you have to work pretty hard to make them happen.
While it's come up a couple of times in 28 years, it's not been a huge

Changing it isn't really a high priority right now, but if I were to do
it, I would probably add an option to avoid breaking backwards compatibility.


``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]