zsh-workers
 help / color / mirror / code / Atom feed
* The default $fpath
@ 2014-09-06 12:00 Tanu Kaskinen
  2014-09-06 16:06 ` Frank Terbeck
  2014-09-06 18:45 ` Peter Stephenson
  0 siblings, 2 replies; 16+ messages in thread
From: Tanu Kaskinen @ 2014-09-06 12:00 UTC (permalink / raw)
  To: zsh-workers

Hello,

I have a complaint about the default $fpath contents.

Let's assume that I write a program, let's call it "Foo". I want to 
support Zsh completion for Foo, so I write a shell completion script. By 
default, if someone builds Foo from source, Foo should be installed 
under prefix /usr/local. Distributions will install Foo under prefix /usr.

Regardless of whether Foo is installed under /usr or /usr/local, I want 
the Zsh completion to Just Work. I think it should not matter whether 
the Zsh completion is installed under /usr/share/zsh/site-functions or 
/usr/local/share/zsh/site-functions, the completion script should be 
picked up by Zsh either way.

On some distributions this appears to work, but not all. At least 
Fedora's Zsh doesn't include /usr/local/share/zsh/site-functions in the 
default $fpath. This doesn't seem to be Fedora's fault. As far as I can 
see, Zsh upstream doesn't include /usr/local/share/zsh/site-functions in 
$fpath if the install prefix is /usr.

Would a patch be accepted that adds /usr/local/share/zsh/site-functions 
to $fpath always, no matter what the install prefix is?

-- 
Tanu


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: The default $fpath
  2014-09-06 12:00 The default $fpath Tanu Kaskinen
@ 2014-09-06 16:06 ` Frank Terbeck
  2014-09-06 18:45 ` Peter Stephenson
  1 sibling, 0 replies; 16+ messages in thread
From: Frank Terbeck @ 2014-09-06 16:06 UTC (permalink / raw)
  To: Tanu Kaskinen; +Cc: zsh-workers

Hello Tanu,

Tanu Kaskinen wrote:
> Let's assume that I write a program, let's call it "Foo". I want to support Zsh
> completion for Foo, so I write a shell completion script. By default, if
> someone builds Foo from source, Foo should be installed under prefix
> /usr/local. Distributions will install Foo under prefix /usr.
>
> Regardless of whether Foo is installed under /usr or /usr/local, I want the Zsh
> completion to Just Work. I think it should not matter whether the Zsh
> completion is installed under /usr/share/zsh/site-functions or
> /usr/local/share/zsh/site-functions, the completion script should be picked up
> by Zsh either way.
>
> On some distributions this appears to work, but not all. At least Fedora's Zsh
> doesn't include /usr/local/share/zsh/site-functions in the default $fpath. This
> doesn't seem to be Fedora's fault. As far as I can see, Zsh upstream doesn't
> include /usr/local/share/zsh/site-functions in $fpath if the install prefix is
> /usr.
>
> Would a patch be accepted that adds /usr/local/share/zsh/site-functions to
> $fpath always, no matter what the install prefix is?

I think this is a problem that should be tackled in vendor packages.

Here's how we do it in debian land, using build-time parameters passed
to the ‘configure’ script: We set the ‘site-functions’ location to
/usr/local by using:

  --enable-site-fndir=/usr/local/share/zsh/site-functions

This solves the problem of site-specific additions out of the scope of
the package system. Now there's the problem, that other packages, that
may want to install zsh completions can't just write to /usr/local... To
solve that we use

  --enable-additional-fpath=/usr/share/zsh/vendor-functions,/usr/share/zsh/vendor-completions

And we just tell other packages to install completions to

  /usr/share/zsh/vendor-completions

This would solve what you're asking for, in addition to leaving a clean
place for completions from other packages in a vendor's repository.


Regards, Frank

-- 
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
                                                  -- RFC 1925


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: The default $fpath
  2014-09-06 12:00 The default $fpath Tanu Kaskinen
  2014-09-06 16:06 ` Frank Terbeck
@ 2014-09-06 18:45 ` Peter Stephenson
  2014-09-06 19:10   ` Frank Terbeck
  1 sibling, 1 reply; 16+ messages in thread
From: Peter Stephenson @ 2014-09-06 18:45 UTC (permalink / raw)
  To: zsh-workers

On Sat, 06 Sep 2014 15:00:51 +0300
Tanu Kaskinen <tanu.kaskinen@linux.intel.com> wrote:
> Would a patch be accepted that adds /usr/local/share/zsh/site-functions 
> to $fpath always, no matter what the install prefix is?

It is a bit frustrating that there's nowhere you can put a function and
guarantee that a user will find it without altering the path.  Granted
you *can* put it somewhere else where it'll be found, that doesn't mean
you should be forced to, if there are no gotchas to do with having a
standard location.

I'm not sure what the disadvantage would be, if any.  The best I can
come up with is that if there is an actual installation in /usr/local it
might have a version of a function that's incompatible with the standard
system version.  I'm not sure how likely this would be with user-defined
as opposed to distributed functions, though, since if you consciously
decide to put something in /usr/local you can decide to put a different
version under /usr (or wherever), too.  But quite possibly people
writing distributions sometimes interpret "site" to mean "distribution".
Even so, you could put the directory at the end of the fpath so it only
finds it if it didn't find it anywhere else.  But maybe you meant it to
be a replacement for a distributed function... sigh.

Discuss.

pws


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: The default $fpath
  2014-09-06 18:45 ` Peter Stephenson
@ 2014-09-06 19:10   ` Frank Terbeck
  2014-09-06 23:04     ` Peter Stephenson
  0 siblings, 1 reply; 16+ messages in thread
From: Frank Terbeck @ 2014-09-06 19:10 UTC (permalink / raw)
  To: zsh-workers

Hello Peter,

Peter Stephenson wrote:
[...]
> It is a bit frustrating that there's nowhere you can put a function and
> guarantee that a user will find it without altering the path.  Granted
> you *can* put it somewhere else where it'll be found, that doesn't mean
> you should be forced to, if there are no gotchas to do with having a
> standard location.

Do you mean making the default ‘--enable-site-fndir’ independent of
installation prefix to “/usr/local/share/zsh/site-functions”?

I think that would make sense. Thinking about it a little more, I find
it a bit out of the ordinary that ‘site-functions’ would *not* be within
“/usr/local”. (Personally, I rarely see that situation myself, because I
either use debian's zsh package or build from source with installation
prefix set to the default, which is “/usr/local”.


Regards, Frank


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: The default $fpath
  2014-09-06 19:10   ` Frank Terbeck
@ 2014-09-06 23:04     ` Peter Stephenson
  2014-09-07  3:44       ` Bart Schaefer
  0 siblings, 1 reply; 16+ messages in thread
From: Peter Stephenson @ 2014-09-06 23:04 UTC (permalink / raw)
  To: zsh-workers

On Sat, 06 Sep 2014 21:10:14 +0200
Frank Terbeck <ft@bewatermyfriend.org> wrote:
> Peter Stephenson wrote:
> > It is a bit frustrating that there's nowhere you can put a function and
> > guarantee that a user will find it without altering the path.  Granted
> > you *can* put it somewhere else where it'll be found, that doesn't mean
> > you should be forced to, if there are no gotchas to do with having a
> > standard location.
> 
> Do you mean making the default ‘--enable-site-fndir’ independent of
> installation prefix to “/usr/local/share/zsh/site-functions”?

I think that would eliminate any existing site-functions,
e.g. /usr/share/zsh/site-functions when the prefix is /usr, from the
path.  That's probably a bad idea as (i) it changes the behaviour of an
updated installation in the same location (ii) some automated site
installation script might be using it.

I think it needs to be additional.  What I'm less clear about is where
it would go in the path.

If we made the change, we might, however, want to document that from now on
/usr/local/share/zsh/site-functions is recommended if the functions are
to be available to all instances of zsh.

pws


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: The default $fpath
  2014-09-06 23:04     ` Peter Stephenson
@ 2014-09-07  3:44       ` Bart Schaefer
  2014-09-07 18:31         ` Peter Stephenson
  0 siblings, 1 reply; 16+ messages in thread
From: Bart Schaefer @ 2014-09-07  3:44 UTC (permalink / raw)
  To: zsh-workers

On Sep 7, 12:04am, Peter Stephenson wrote:
}
} I think it needs to be additional.  What I'm less clear about is where
} it would go in the path.

To satisfy the original request, it'd have to be both additional, and
a fixed location independent of the locations chosen by the package
builder.  I'm not sure it's possible to satisfy the latter constraint.

As Frank pointed out, configure already has --enable-additional-fpath
which adds locations to the end of the path.  One possibility is to
declare a default value for that.

Or we could do the very zsh-ish thing of inventing TWO such locations
and putting one at each end of the fpath.

} If we made the change, we might, however, want to document that from
} now on /usr/local/share/zsh/site-functions is recommended if the
} functions are to be available to all instances of zsh.

Shouldn't we document that already/anyway?  That is after all the first
directory in the existing default fpath.

(Given that, it would seem we already have a location at the beginning
of the path and if we need anything we need one at the other end.)


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: The default $fpath
  2014-09-07  3:44       ` Bart Schaefer
@ 2014-09-07 18:31         ` Peter Stephenson
  2014-09-07 19:37           ` Vin Shelton
  0 siblings, 1 reply; 16+ messages in thread
From: Peter Stephenson @ 2014-09-07 18:31 UTC (permalink / raw)
  To: zsh-workers

On Sat, 06 Sep 2014 20:44:05 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Sep 7, 12:04am, Peter Stephenson wrote:
> }
> } I think it needs to be additional.  What I'm less clear about is where
> } it would go in the path.
> 
> To satisfy the original request, it'd have to be both additional, and
> a fixed location independent of the locations chosen by the package
> builder.  I'm not sure it's possible to satisfy the latter constraint.

The proposal is quite simply to add /usr/local/share/zsh/site-functions,
that and nothing else, independent of any other factors, to the default
fpath at some point.  I'd like to know if there are any significant
disadvantages to this before we even think about anything more
complicated.

pws


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: The default $fpath
  2014-09-07 18:31         ` Peter Stephenson
@ 2014-09-07 19:37           ` Vin Shelton
  2014-09-07 19:53             ` Tanu Kaskinen
  0 siblings, 1 reply; 16+ messages in thread
From: Vin Shelton @ 2014-09-07 19:37 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: Zsh Hackers' List

On Sun, Sep 7, 2014 at 2:31 PM, Peter Stephenson
<p.w.stephenson@ntlworld.com> wrote:
> The proposal is quite simply to add /usr/local/share/zsh/site-functions,
> that and nothing else, independent of any other factors, to the default
> fpath at some point.  I'd like to know if there are any significant
> disadvantages to this before we even think about anything more
> complicated.

I don't have a /usr/local on my system, I use /opt instead.  Will it
be possible to override the root?

  - Vin


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: The default $fpath
  2014-09-07 19:37           ` Vin Shelton
@ 2014-09-07 19:53             ` Tanu Kaskinen
  2014-09-07 20:40               ` Peter Stephenson
  0 siblings, 1 reply; 16+ messages in thread
From: Tanu Kaskinen @ 2014-09-07 19:53 UTC (permalink / raw)
  To: Vin Shelton; +Cc: Peter Stephenson, Zsh Hackers' List

On Sun, 2014-09-07 at 15:37 -0400, Vin Shelton wrote:
> On Sun, Sep 7, 2014 at 2:31 PM, Peter Stephenson
> <p.w.stephenson@ntlworld.com> wrote:
> > The proposal is quite simply to add /usr/local/share/zsh/site-functions,
> > that and nothing else, independent of any other factors, to the default
> > fpath at some point.  I'd like to know if there are any significant
> > disadvantages to this before we even think about anything more
> > complicated.
> 
> I don't have a /usr/local on my system, I use /opt instead.  Will it
> be possible to override the root?

I think it's probably a good idea to make the
non-install-prefix-dependent directory configurable. I'd be interested,
though, is /opt used exactly in the same way as /usr/local on your
system? That is, if you build a program called foo from source, do you
pass --prefix=/opt to foo's configure script, so foo's zsh completion
files will end up in /opt/share/zsh/site-functions?

My understanding is that usually /opt is used so that you'd pass
--prefix=/opt/foo to foo's configure script, so the completions will end
up in /opt/foo/share/zsh/site-functions, and there's no way zsh is going
to find them from there. So, if you use /opt, you'll anyway need to pass
some extra configure parameter when building foo, so that foo's
completion files will be installed to /usr/share/zsh/site-functions (or
whatever location you prefer). In this scheme it doesn't really matter
if you can't override the non-install-prefix-dependent zsh function
directory.

-- 
Tanu


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: The default $fpath
  2014-09-07 19:53             ` Tanu Kaskinen
@ 2014-09-07 20:40               ` Peter Stephenson
  2014-09-07 21:01                 ` Bart Schaefer
  0 siblings, 1 reply; 16+ messages in thread
From: Peter Stephenson @ 2014-09-07 20:40 UTC (permalink / raw)
  To: Zsh Hackers' List

On Sun, 07 Sep 2014 22:53:02 +0300
Tanu Kaskinen <tanu.kaskinen@linux.intel.com> wrote:
> > I don't have a /usr/local on my system, I use /opt instead.  Will it
> > be possible to override the root?
> 
> I think it's probably a good idea to make the
> non-install-prefix-dependent directory configurable.

No, it won't be configurable at compile time.

You can already set fpath the way you want in an initialisation file.
The user can override it any way they like, so there's nothing you can
do to force them to use a particular path anyway.  So it's already
infinitely configurable by means of shell code, which is much more
flexible than configuration for compilation; if you're doing that the
builtin path becomes irrelevant.  As the shell doesn't use the directory
itself it doesn't really care at the point of installation, so there's
no gain in compiling in something you can change at run time.

The proposal is simply to provide a directory where there's some
reasonable chance it will be found by all installations of the shell on
the same system regardless of configuration.  If you don't care about
that particular directory because you use others, if you want to set up
your own system, and in particular if you have your own custom setup
files so the shell paths are how you like them, then this doesn't
interest you one way or the other.

In short, this is for people who *don't* want to configure the system
themselves; if everyone did, the problem wouldn't have arisen.  There
are already plenty of ways of doing it for those who do.  It is a
command shell, after all.   If this builtin default becomes configurable
to use different directories the whole advantage is lost; it's far better
to use common run-time code to ensure a non-default directory.

I seem to be labouring explaining this point...

I'd really like to know if there are any problems caused by *this*
proposal, adding /usr/local/share/zsh/site-functions to the compiled-in
path.

pws


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: The default $fpath
  2014-09-07 20:40               ` Peter Stephenson
@ 2014-09-07 21:01                 ` Bart Schaefer
  2014-09-08 10:23                   ` Peter Stephenson
  0 siblings, 1 reply; 16+ messages in thread
From: Bart Schaefer @ 2014-09-07 21:01 UTC (permalink / raw)
  To: Zsh Hackers' List

On Sep 7,  9:40pm, Peter Stephenson wrote:
}
} You can already set fpath the way you want in an initialisation file.

Exactly.

} The proposal is simply to provide a directory where there's some
} reasonable chance it will be found by all installations of the shell on
} the same system regardless of configuration.

Actually, I think the proposal is to provide a directory where all OTHER
softwares' configuration systems can install shell functions so that they
are found by all installations of zsh on ANY system, regardless of the
local-zsh-builder's and/or system-zsh-packager's idea of the path to the
functions provided by zsh itself.

} [...] If this builtin default becomes configurable
} to use different directories the whole advantage is lost; it's far better
} to use common run-time code to ensure a non-default directory.

This point, however, holds true either way.  I just think it's impossible
to promise that the directory will exist; certainly the zsh installer
should not unilaterally create it.

} I'd really like to know if there are any problems caused by *this*
} proposal, adding /usr/local/share/zsh/site-functions to the compiled-in
} path.

I can't think of any; presumably the configure-time (?) code for this
would resemble

    if [ X$ac_default_prefix != X/usr/local ]
    then fixed_sitefndir=/usr/local/zsh/site-functions
    elif [ X$tzsh_name != Xzsh ]
    then fixed_sitefndir=/usr/local/zsh/site-functions
    else fixed_sitefndir=''
    fi

and then zsh.mdd would use something like

    echo '#define FIXED_FPATH_DIR "'$(fixed_sitefndir)'"' >> zshpaths.h.tmp;

and finally somewhere in Src/init.c the fpath would be prefixed with the
value of FIXED_FPATH_DIR if it is non-empty.

The worst that happens is that /usr/local is a remote file system (which
would seem rather unlikely) and zsh gets slowed down every time fpath is
searched for a directory there that doesn't exist.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: The default $fpath
  2014-09-07 21:01                 ` Bart Schaefer
@ 2014-09-08 10:23                   ` Peter Stephenson
  2014-09-08 11:16                     ` Frank Terbeck
  0 siblings, 1 reply; 16+ messages in thread
From: Peter Stephenson @ 2014-09-08 10:23 UTC (permalink / raw)
  To: Zsh Hackers' List

On Sun, 07 Sep 2014 14:01:22 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:
> } The proposal is simply to provide a directory where there's some
> } reasonable chance it will be found by all installations of the shell on
> } the same system regardless of configuration.
> 
> Actually, I think the proposal is to provide a directory where all OTHER
> softwares' configuration systems can install shell functions so that they
> are found by all installations of zsh on ANY system, regardless of the
> local-zsh-builder's and/or system-zsh-packager's idea of the path to the
> functions provided by zsh itself.

Yes, indeed, the idea is to make this as global as possible.  If you
happen not to use this directory, that's fine: (i) the shell itself and
the standard installation stuff don't care (ii) presumably, therefore,
you've made your own arrangements for fpath, which is the best guarantee
of consistency on your system anyway.

> } [...] If this builtin default becomes configurable
> } to use different directories the whole advantage is lost; it's far better
> } to use common run-time code to ensure a non-default directory.
> 
> This point, however, holds true either way.  I just think it's impossible
> to promise that the directory will exist; certainly the zsh installer
> should not unilaterally create it.

Yes, I agree with both points.  I don't think that removes its utility,
though.

> } I'd really like to know if there are any problems caused by *this*
> } proposal, adding /usr/local/share/zsh/site-functions to the compiled-in
> } path.
> 
> I can't think of any; presumably the configure-time (?) code for this
> would resemble
> 
>     if [ X$ac_default_prefix != X/usr/local ]
>     then fixed_sitefndir=/usr/local/zsh/site-functions
>     elif [ X$tzsh_name != Xzsh ]
>     then fixed_sitefndir=/usr/local/zsh/site-functions
>     else fixed_sitefndir=''
>     fi
> 
> and then zsh.mdd would use something like
> 
>     echo '#define FIXED_FPATH_DIR "'$(fixed_sitefndir)'"' >> zshpaths.h.tmp;
> 
> and finally somewhere in Src/init.c the fpath would be prefixed with the
> value of FIXED_FPATH_DIR if it is non-empty.

OK, so that's an answer to my other open question: you're suggesting (i)
if the prefix is /usr/local and this is a standard zsh installation
we keep things the way they are (ii) otherwise the new component is
the first thing to be tried in the default fpath.

> The worst that happens is that /usr/local is a remote file system (which
> would seem rather unlikely) and zsh gets slowed down every time fpath is
> searched for a directory there that doesn't exist.

Does seem a bit perverse...  we could add a --disable-fixed-sitenfndir
for the paranoid.  In other words, this is a simple boolean; either you
want the shell to be compatible with this pseudostandard, or you don't.

pws


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: The default $fpath
  2014-09-08 10:23                   ` Peter Stephenson
@ 2014-09-08 11:16                     ` Frank Terbeck
  2014-09-20 19:04                       ` Peter Stephenson
  0 siblings, 1 reply; 16+ messages in thread
From: Frank Terbeck @ 2014-09-08 11:16 UTC (permalink / raw)
  To: Zsh Hackers' List

Peter Stephenson wrote:
> Bart Schaefer <schaefer@brasslantern.com> wrote:
>> I can't think of any; presumably the configure-time (?) code for this
>> would resemble
>> 
>>     if [ X$ac_default_prefix != X/usr/local ]
>>     then fixed_sitefndir=/usr/local/zsh/site-functions
>>     elif [ X$tzsh_name != Xzsh ]
>>     then fixed_sitefndir=/usr/local/zsh/site-functions
>>     else fixed_sitefndir=''
>>     fi
>> 
>> and then zsh.mdd would use something like
>> 
>>     echo '#define FIXED_FPATH_DIR "'$(fixed_sitefndir)'"' >> zshpaths.h.tmp;
>> 
>> and finally somewhere in Src/init.c the fpath would be prefixed with the
>> value of FIXED_FPATH_DIR if it is non-empty.
>
> OK, so that's an answer to my other open question: you're suggesting (i)
> if the prefix is /usr/local and this is a standard zsh installation
> we keep things the way they are (ii) otherwise the new component is
> the first thing to be tried in the default fpath.

It should probably also check if --enable-site-fndir points to the
location in ‘/usr/local’, not just ‘prefix’. What would the order of
these entries be?

  1. Fixed site-functions (the new entry)
  2. Prefix-based/--enable-site-fndir site-functions
  3. Entries added by --enable-additional-fpath
  4. All the rest of it, like it is now.

I think that would make sense. That's basically the way it is right now,
plus the fixed directory at the very front (unless it's the same as the
old ‘site-functions’ location).

>> The worst that happens is that /usr/local is a remote file system (which
>> would seem rather unlikely) and zsh gets slowed down every time fpath is
>> searched for a directory there that doesn't exist.
>
> Does seem a bit perverse...  we could add a --disable-fixed-sitenfndir
> for the paranoid.  In other words, this is a simple boolean; either you
> want the shell to be compatible with this pseudostandard, or you don't.

That does sound like a plan, but I'd say that sysadmins for systems like
that could also do:

  % zsh -fc 'print -l $fpath'

...filter out entries that would cause problems like that and set an
amended $fpath in the global ‘zshenv’ file. I don't know which solution
would be preferable...


Regards, Frank


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: The default $fpath
  2014-09-08 11:16                     ` Frank Terbeck
@ 2014-09-20 19:04                       ` Peter Stephenson
  2014-09-20 19:36                         ` Peter Stephenson
  0 siblings, 1 reply; 16+ messages in thread
From: Peter Stephenson @ 2014-09-20 19:04 UTC (permalink / raw)
  To: Zsh Hackers' List

On Mon, 08 Sep 2014 13:16:37 +0200
Frank Terbeck <ft@bewatermyfriend.org> wrote:
> Peter Stephenson wrote:
> > Bart Schaefer <schaefer@brasslantern.com> wrote:
> >> I can't think of any; presumably the configure-time (?) code for this
> >> would resemble
> >> 
> >>     if [ X$ac_default_prefix != X/usr/local ]
> >>     then fixed_sitefndir=/usr/local/zsh/site-functions
> >>     elif [ X$tzsh_name != Xzsh ]
> >>     then fixed_sitefndir=/usr/local/zsh/site-functions
> >>     else fixed_sitefndir=''
> >>     fi
> >> 
> >> and then zsh.mdd would use something like
> >> 
> >>     echo '#define FIXED_FPATH_DIR "'$(fixed_sitefndir)'"' >> zshpaths.h.tmp;
> >> 
> >> and finally somewhere in Src/init.c the fpath would be prefixed with the
> >> value of FIXED_FPATH_DIR if it is non-empty.
> >
> > OK, so that's an answer to my other open question: you're suggesting (i)
> > if the prefix is /usr/local and this is a standard zsh installation
> > we keep things the way they are (ii) otherwise the new component is
> > the first thing to be tried in the default fpath.
> 
> It should probably also check if --enable-site-fndir points to the
> location in ‘/usr/local’, not just ‘prefix’.

This looks plausible, but it'll need trying out in a few different
configurations.  I'll do a sanity check after I've committed it.

diff --git a/Src/init.c b/Src/init.c
index d536978..40f46a8 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -770,7 +770,8 @@ setupvals(void)
     struct timezone dummy_tz;
     char *ptr;
     int i, j;
-#if defined(SITEFPATH_DIR) || defined(FPATH_DIR) || defined (ADDITIONAL_FPATH)
+#if defined(SITEFPATH_DIR) || defined(FPATH_DIR) || defined (ADDITIONAL_FPATH) || defined(FIXED_FPATH_DIR)
+#define FPATH_NEEDS_INIT 1
     char **fpathptr;
 # if defined(FPATH_DIR) && defined(FPATH_SUBDIRS)
     char *fpath_subdirs[] = FPATH_SUBDIRS;
@@ -779,11 +780,17 @@ setupvals(void)
     char *more_fndirs[] = ADDITIONAL_FPATH;
     int more_fndirs_len;
 # endif
+# ifdef FIXED_FPATH_DIR
+#  define FIXED_FPATH_LEN 1
+# else
+#  define FIXED_FPATH_LEN 0
+# endif
 # ifdef SITEFPATH_DIR
-    int fpathlen = 1;
+#  define SITE_FPATH_LEN 1
 # else
-    int fpathlen = 0;
+#  define SITE_FPATH_LEN 0
 # endif
+    int fpathlen = FIXED_FPATH_LEN + SITE_FPATH_LEN;
 #endif
     int close_fds[10], tmppipe[2];
 
@@ -862,23 +869,27 @@ setupvals(void)
     manpath  = mkarray(NULL);
     fignore  = mkarray(NULL);
 
-#if defined(SITEFPATH_DIR) || defined(FPATH_DIR) || defined(ADDITIONAL_FPATH)
+#ifdef FPATH_NEEDS_INIT
 # ifdef FPATH_DIR
 #  ifdef FPATH_SUBDIRS
     fpathlen += sizeof(fpath_subdirs)/sizeof(char *);
-#  else
+#  else /* FPATH_SUBDIRS */
     fpathlen++;
-#  endif
-# endif
+#  endif /* FPATH_SUBDIRS */
+# endif /* FPATH_DIR */
 # if defined(ADDITIONAL_FPATH)
     more_fndirs_len = sizeof(more_fndirs)/sizeof(char *);
     fpathlen += more_fndirs_len;
-# endif
+# endif /* ADDITONAL_FPATH */
     fpath = fpathptr = (char **)zalloc((fpathlen+1)*sizeof(char *));
+# ifdef FIXED_FPATH_DIR
+    *fpathptr++ = ztrdup(FIXED_FPATH_DIR);
+    fpathlen--;
+# endif
 # ifdef SITEFPATH_DIR
     *fpathptr++ = ztrdup(SITEFPATH_DIR);
     fpathlen--;
-# endif
+# endif /* SITEFPATH_DIR */
 # if defined(ADDITIONAL_FPATH)
     for (j = 0; j < more_fndirs_len; j++)
 	*fpathptr++ = ztrdup(more_fndirs[j]);
@@ -897,9 +908,9 @@ setupvals(void)
 #  endif
 # endif
     *fpathptr = NULL;
-#else
+#else /* FPATH_NEEDS_INIT */
     fpath    = mkarray(NULL);
-#endif
+#endif /* FPATH_NEEDS_INIT */
 
     mailpath = mkarray(NULL);
     watch    = mkarray(NULL);
diff --git a/Src/zsh.mdd b/Src/zsh.mdd
index cec3eda..9a8c923 100644
--- a/Src/zsh.mdd
+++ b/Src/zsh.mdd
@@ -73,6 +73,9 @@ zshpaths.h: Makemod $(CONFIG_INCS)
 	@if test x$(sitefndir) != xno; then \
 	  echo '#define SITEFPATH_DIR "'$(sitefndir)'"' >> zshpaths.h.tmp; \
 	fi
+	@if test x$(fixed_sitefndir) != x; then \
+	  echo '#define FIXED_FPATH_DIR "'$(fixed_sitefndir)'"' >> zshpaths.h.tmp; \
+        fi
 	@if test x$(fndir) != xno; then \
 	  echo '#define FPATH_DIR "'$(fndir)'"' >> zshpaths.h.tmp; \
 	  if test x$(FUNCTIONS_SUBDIRS) != x && \
diff --git a/configure.ac b/configure.ac
index 37f3585..68a2e91 100644
--- a/configure.ac
+++ b/configure.ac
@@ -315,6 +315,18 @@ else
   sitefndir="$enableval"
 fi], [sitefndir=${datadir}/${tzsh_name}/site-functions])
 
+dnl Add /usr/local/share/zsh/site-functions if not yet present.
+dnl It might be present owing to an explicit sitefndir or the install
+dnl prefix if the shell is installed under the name "zsh".
+if test X$sitefndir = X/usr/local/zsh/site-functions
+then fixed_sitefndir=''
+elif test X$ac_default_prefix != X/usr/local
+then fixed_sitefndir=/usr/local/zsh/site-functions
+elif test X$tzsh_name != Xzsh
+then fixed_sitefndir=/usr/local/zsh/site-functions
+else fixed_sitefndir=''
+fi
+
 ifdef([function_subdirs],[undefine([function_subdirs])])
 AC_ARG_ENABLE(function-subdirs,
 AC_HELP_STRING([--enable-function-subdirs], [install functions in subdirectories]))
@@ -340,6 +352,7 @@ AC_SUBST(runhelp)dnl
 AC_SUBST(additionalfpath)dnl
 AC_SUBST(fndir)dnl
 AC_SUBST(sitefndir)dnl
+AC_SUBST(fixed_sitefndir)dnl
 AC_SUBST(FUNCTIONS_SUBDIRS)dnl
 
 dnl Directories for scripts such as newuser.


-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: The default $fpath
  2014-09-20 19:04                       ` Peter Stephenson
@ 2014-09-20 19:36                         ` Peter Stephenson
  2014-09-20 20:00                           ` Peter Stephenson
  0 siblings, 1 reply; 16+ messages in thread
From: Peter Stephenson @ 2014-09-20 19:36 UTC (permalink / raw)
  To: Zsh Hackers' List

On Sat, 20 Sep 2014 20:04:23 +0100
Peter Stephenson <p.w.stephenson@ntlworld.com> wrote:
> +dnl Add /usr/local/share/zsh/site-functions if not yet present.
> +dnl It might be present owing to an explicit sitefndir or the install
> +dnl prefix if the shell is installed under the name "zsh".
> +if test X$sitefndir = X/usr/local/zsh/site-functions
> +then fixed_sitefndir=''
> +elif test X$ac_default_prefix != X/usr/local
> +then fixed_sitefndir=/usr/local/zsh/site-functions
> +elif test X$tzsh_name != Xzsh
> +then fixed_sitefndir=/usr/local/zsh/site-functions
> +else fixed_sitefndir=''
> +fi
> +

ac_default_prefix is always /usr/local, it's not the --prefix.

But surely the only place we're ever likely to get an other copy of the
directory from is $sitefndir, whether set explicitly or based on the
prefix?

Also missed a substitution.

Also, somehow, got the wrong directory, missing out the "share".

But apart from that...

diff --git a/Config/defs.mk.in b/Config/defs.mk.in
index f6ea5c1..3c84610 100644
--- a/Config/defs.mk.in
+++ b/Config/defs.mk.in
@@ -47,6 +47,7 @@ mandir          = @mandir@
 datarootdir     = @datarootdir@
 datadir         = @datadir@
 fndir           = @fndir@
+fixed_sitefndir = @fixed_sitefndir@
 sitefndir       = @sitefndir@
 scriptdir       = @scriptdir@
 sitescriptdir   = @sitescriptdir@
diff --git a/configure.ac b/configure.ac
index 68a2e91..b202940 100644
--- a/configure.ac
+++ b/configure.ac
@@ -315,16 +315,11 @@ else
   sitefndir="$enableval"
 fi], [sitefndir=${datadir}/${tzsh_name}/site-functions])
 
-dnl Add /usr/local/share/zsh/site-functions if not yet present.
-dnl It might be present owing to an explicit sitefndir or the install
-dnl prefix if the shell is installed under the name "zsh".
-if test X$sitefndir = X/usr/local/zsh/site-functions
+dnl Add /usr/local/share/zsh/site-functions if not yet present
+dnl owing to $sitefndir, whether or not explicitly given.
+if test X$sitefndir = X/usr/local/share/zsh/site-functions
 then fixed_sitefndir=''
-elif test X$ac_default_prefix != X/usr/local
-then fixed_sitefndir=/usr/local/zsh/site-functions
-elif test X$tzsh_name != Xzsh
-then fixed_sitefndir=/usr/local/zsh/site-functions
-else fixed_sitefndir=''
+else fixed_sitefndir=/usr/local/share/zsh/site-functions
 fi
 
 ifdef([function_subdirs],[undefine([function_subdirs])])


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: The default $fpath
  2014-09-20 19:36                         ` Peter Stephenson
@ 2014-09-20 20:00                           ` Peter Stephenson
  0 siblings, 0 replies; 16+ messages in thread
From: Peter Stephenson @ 2014-09-20 20:00 UTC (permalink / raw)
  To: Zsh Hackers' List

On Sat, 20 Sep 2014 20:36:48 +0100
Peter Stephenson <p.w.stephenson@ntlworld.com> wrote:
> But surely the only place we're ever likely to get an other copy of the
> directory from is $sitefndir, whether set explicitly or based on the
> prefix?

Oh, I see.  If it's not set explicitly, it hasn't been expanded yet,
hence the test for the parts.  And the parts haven't been expanded.
And prefix may be set to NONE to use the default prefix but may also
explicitly be set to /usr/local.

Er...

I couldn't be bothered to test if datadir had been moved from
${prefix}/share.

An eval would be more effective but less safe.

diff --git a/configure.ac b/configure.ac
index b202940..1d77098 100644
--- a/configure.ac
+++ b/configure.ac
@@ -317,9 +317,17 @@ fi], [sitefndir=${datadir}/${tzsh_name}/site-functions])
 
 dnl Add /usr/local/share/zsh/site-functions if not yet present
 dnl owing to $sitefndir, whether or not explicitly given.
+dnl If not explicitly given, it hasn't been expanded yet.
 if test X$sitefndir = X/usr/local/share/zsh/site-functions
 then fixed_sitefndir=''
-else fixed_sitefndir=/usr/local/share/zsh/site-functions
+elif test X$prefix != X/usr/local; then
+  if test X$prefix = XNONE && test X$ac_default_prefix = X/usr/local
+  then fixed_sitefndir=''
+  else fixed_sitefndir=/usr/local/share/zsh/site-functions
+  fi
+elif test X$tzsh_name != Xzsh
+then fixed_sitefndir=/usr/local/share/zsh/site-functions
+else fixed_sitefndir=''
 fi
 
 ifdef([function_subdirs],[undefine([function_subdirs])])


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2014-09-20 20:00 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-06 12:00 The default $fpath Tanu Kaskinen
2014-09-06 16:06 ` Frank Terbeck
2014-09-06 18:45 ` Peter Stephenson
2014-09-06 19:10   ` Frank Terbeck
2014-09-06 23:04     ` Peter Stephenson
2014-09-07  3:44       ` Bart Schaefer
2014-09-07 18:31         ` Peter Stephenson
2014-09-07 19:37           ` Vin Shelton
2014-09-07 19:53             ` Tanu Kaskinen
2014-09-07 20:40               ` Peter Stephenson
2014-09-07 21:01                 ` Bart Schaefer
2014-09-08 10:23                   ` Peter Stephenson
2014-09-08 11:16                     ` Frank Terbeck
2014-09-20 19:04                       ` Peter Stephenson
2014-09-20 19:36                         ` Peter Stephenson
2014-09-20 20:00                           ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).