This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Attn: base-files maintainer] Changing /etc/profile to add more shell-dependent settings

On Wed, Oct 14, 2015 at 06:53:27PM +0200, Achim Gratz wrote:
> Adam Dinwoodie writes:
> > The /etc/defaults/etc/profile file in base-files has a section at the
> > end to import scripts in /etc/profile.d, but this currently only works
> > with zsh.
> No, this section is specific to zsh and probably even the wrong thing to
> do -- /etc/profile is only ever intended to be run by POSIX compatible
> shells (or shells in POSIX mode if they support that notion).  I've kept
> it alive for the time being since nothing packaged in Cygwin depends on
> it.  For anybody else using it for their personal customization it must
> already be working.
> > Can this section be expanded to make calls as appropriate for other
> > shells?  I'm particularly interested in Fish and Bash, although I don't
> > see any reason to limit the change to those shells.
> Bash can use ".sh" with the proviso that you can only use the POSIX
> subset of its functionality.  Other, non-POSIX, shells should implement
> something similar in their own startup scripts.  Csh already does, I
> don't know enough about fish to tell how to insert something into its
> start-up.  IIRC, Zsh also has a way to run extra code besides just the
> one in /etc/profile if you somehow need that.
> > I care about this because I'm currently investigating packaging fzf[0].
> > The obvious way to include the shell-specific keyboard shortcuts for fzf
> > is to add them to /etc/profile.d, but currently that only works for
> > Z-Shell.
> Look again, and don't let yourself get distracted by the zsh specific
> code.  :-)

Mmmkay.  So I'll find somewhere else to put the zsh and fish specific
scripts (I've already found somewhere for fish, and I'll take your word
that zsh also has a similar directory).

That, however, doesn't give me anywhere to put the Bash fzf script.
It's not POSIX compliant, so I don't want to use ".sh".  I can't
find any directory other than /etc/profile.d that Bash trawls, though.

The only other option I can think of is to rename the .bash file to .sh
and to patch it to check $BASH_VERSION before running the Bash-specific
code.  That seems fragile though -- it means putting Bashisms in a
script that may be run by non-Bash shells (even if it's gated by
checking $BASH_VERSION), and it means a patch of the upstream fzf Bash
script in a way that's essentially just duplicating code already in

(The upstream solution to this is to add code to the user's ~/.bashrc to
source the relevant scripts, but I don't think that's feasible when
installing the scripts via setup-*.exe.)

Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]