Re: [PATCH 1/1] mingw: handle absolute paths in expand_user_path()
- From
Jeff King <peff@peff.net>
- Date
- Nov 9, 2018, 10:19 UTC
- Message-ID
- <20181109101918.GC7410@sigill.intra.peff.net>
- In-Reply-To
- <nycvar.QRO.7.76.6.1811081639210.39@tvgsbejvaqbjf.bet>
On Thu, Nov 08, 2018 at 04:45:16PM +0100, Johannes Schindelin wrote:
Show 11 quoted lines
> > One thing I had in mind when proposing $VARIABLE is that it opens up a > > namespace for us to expand more things (*) for example $GIT_DIR (from > > ~/.gitconfig). > > > > (*) but in a controlled way, it may look like an environment variable, > > but we only accept a selected few. And it's only expanded at the > > beginning of a path. > > I understand that desire, and I even agree. But the fact that it looks > like an environment variable, but is not, is actually a point in favor of > *not* doing this. It would violate the principle of least astonishment.
I agree that it is potentially surprising. OTOH, it is at least pretty obvious when you see in the wild something like:
[core] foo = $RUNTIME_PREFIX/bar
what it is _trying_ to do. My big concern with "~"-based things is that they're kind of subtle. If I saw:
[core] foo = ~~/bar
I'm not sure what I would think it does. ;)
Show 8 quoted lines
> The form `<RUNTIME_PREFIX>/abc/def` would not be confused with anything > that it is not, I would think. The only thing against this form (at least > that I can think of) is that some people use this way to talk about paths > that vary between different setups, with the implicit assumption that the > reader will "interpolate" this *before* applying. So for example, when I > tell a user to please edit their <GIT_DIR>/config, I implicitly assume > that they know to not type out, literally, <GIT_DIR> but instead fill in > the correct path.
So yeah, some alternative syntax that is verbose but distinct makes sense to me. We use %-substitution elsewhere. Could we do something with that? "%RUNTIME_PREFIX%" gives me too many flashbacks, but something like "%(RUNTIME_PREFIX)" matches our formatting language.
I dunno. I actually do not think "$FOO" is so bad, as long as we clearly document that:
- we do not allow arbitrary $FOO from the environment (though I am
actually not all that opposed to doing so) - we add some special $FOOs that are not actually environment
variables-Peff