public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* [Attn: base-files maintainer] Changing /etc/profile to add more shell-dependent settings
@ 2015-10-14 15:53 Adam Dinwoodie
  2015-10-14 16:20 ` Andrey Repin
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Adam Dinwoodie @ 2015-10-14 15:53 UTC (permalink / raw)
  To: cygwin

Achim,

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.

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.

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.

I'm happy to provide a patch if that'd make things easier.

Adam

[0]: https://github.com/junegunn/fzf

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

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

* Re: [Attn: base-files maintainer] Changing /etc/profile to add more shell-dependent settings
  2015-10-14 15:53 [Attn: base-files maintainer] Changing /etc/profile to add more shell-dependent settings Adam Dinwoodie
@ 2015-10-14 16:20 ` Andrey Repin
  2015-10-14 16:20 ` Yaakov Selkowitz
  2015-10-14 16:53 ` Achim Gratz
  2 siblings, 0 replies; 9+ messages in thread
From: Andrey Repin @ 2015-10-14 16:20 UTC (permalink / raw)
  To: Adam Dinwoodie, cygwin

Greetings, Adam Dinwoodie!

> 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.

It also works for generic ".sh" files (see directly above that monstrous `if`
switch.

> 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.

For what it's worth, I don't know any adopted 'standard' extension for bash,
other than '.sh', which is already covered.

> 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.

As I mentioned earlier, it works for generic .sh files. Also, please pay
attention to the note placed in the zsh section that it is probably a BAD IDEA
to do that in this particular manner.


-- 
With best regards,
Andrey Repin
Wednesday, October 14, 2015 19:13:11

Sorry for my terrible english...


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

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

* Re: [Attn: base-files maintainer] Changing /etc/profile to add more shell-dependent settings
  2015-10-14 15:53 [Attn: base-files maintainer] Changing /etc/profile to add more shell-dependent settings Adam Dinwoodie
  2015-10-14 16:20 ` Andrey Repin
@ 2015-10-14 16:20 ` Yaakov Selkowitz
  2015-10-14 16:32   ` Adam Dinwoodie
  2015-10-14 16:53 ` Achim Gratz
  2 siblings, 1 reply; 9+ messages in thread
From: Yaakov Selkowitz @ 2015-10-14 16:20 UTC (permalink / raw)
  To: cygwin

On Wed, 2015-10-14 at 16:52 +0100, Adam Dinwoodie wrote:
> 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.

Bash is covered by the "profile_d sh" command therein.

> 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.

Note that /etc/profile is only for Bourne-compatible shells; those that
are not must use their own mechanism to accomplish the same thing (e.g.
tcsh in /etc/csh.cshrc).  As fish has a different syntax, it may fall
into this category as well.

--
Yaakov




--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

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

* Re: [Attn: base-files maintainer] Changing /etc/profile to add more shell-dependent settings
  2015-10-14 16:20 ` Yaakov Selkowitz
@ 2015-10-14 16:32   ` Adam Dinwoodie
  0 siblings, 0 replies; 9+ messages in thread
From: Adam Dinwoodie @ 2015-10-14 16:32 UTC (permalink / raw)
  To: cygwin

On Wed, Oct 14, 2015 at 11:20:13AM -0500, Yaakov Selkowitz wrote:
> On Wed, 2015-10-14 at 16:52 +0100, Adam Dinwoodie wrote:
> > 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.
> 
> Bash is covered by the "profile_d sh" command therein.

The `profile_d sh` command is run for all shells that execute that file;
looking at the code that appears to be at least Bash, Korn, Z and Posh.
I'm looking for `profile_d bash` and the like -- fzf's implementation
for Bash isn't going to be appropriate to run for other shells.

> > 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.
> 
> Note that /etc/profile is only for Bourne-compatible shells; those that
> are not must use their own mechanism to accomplish the same thing (e.g.
> tcsh in /etc/csh.cshrc).  As fish has a different syntax, it may fall
> into this category as well.

Okay, I'd assumed Fish would use /etc/profile, but if not I'll look at
finding some alternative for that.

Adam

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

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

* Re: [Attn: base-files maintainer] Changing /etc/profile to add more shell-dependent settings
  2015-10-14 15:53 [Attn: base-files maintainer] Changing /etc/profile to add more shell-dependent settings Adam Dinwoodie
  2015-10-14 16:20 ` Andrey Repin
  2015-10-14 16:20 ` Yaakov Selkowitz
@ 2015-10-14 16:53 ` Achim Gratz
  2015-10-14 17:14   ` Adam Dinwoodie
  2 siblings, 1 reply; 9+ messages in thread
From: Achim Gratz @ 2015-10-14 16:53 UTC (permalink / raw)
  To: cygwin

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.  :-)


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Waldorf MIDI Implementation & additional documentation:
http://Synth.Stromeko.net/Downloads.html#WaldorfDocs

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

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

* Re: [Attn: base-files maintainer] Changing /etc/profile to add more shell-dependent settings
  2015-10-14 16:53 ` Achim Gratz
@ 2015-10-14 17:14   ` Adam Dinwoodie
  2015-10-14 18:35     ` Andrey Repin
  2015-10-14 20:15     ` Achim Gratz
  0 siblings, 2 replies; 9+ messages in thread
From: Adam Dinwoodie @ 2015-10-14 17:14 UTC (permalink / raw)
  To: cygwin

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
/etc/profile.

(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:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

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

* Re: [Attn: base-files maintainer] Changing /etc/profile to add more shell-dependent settings
  2015-10-14 17:14   ` Adam Dinwoodie
@ 2015-10-14 18:35     ` Andrey Repin
  2015-10-14 18:49       ` Adam Dinwoodie
  2015-10-14 20:15     ` Achim Gratz
  1 sibling, 1 reply; 9+ messages in thread
From: Andrey Repin @ 2015-10-14 18:35 UTC (permalink / raw)
  To: Adam Dinwoodie, cygwin

Greetings, Adam Dinwoodie!

> 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.

If my opinion matters, I would advocate making scripts POSIX compliant, unless
there's strong reason to explicitly require shell-dependent functionality.

> 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
> /etc/profile.

> (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.)

It isn't feasible at all, touching user's profile scripts is a ready recipe
for disaster.


-- 
With best regards,
Andrey Repin
Wednesday, October 14, 2015 21:25:05

Sorry for my terrible english...


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

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

* Re: [Attn: base-files maintainer] Changing /etc/profile to add more shell-dependent settings
  2015-10-14 18:35     ` Andrey Repin
@ 2015-10-14 18:49       ` Adam Dinwoodie
  0 siblings, 0 replies; 9+ messages in thread
From: Adam Dinwoodie @ 2015-10-14 18:49 UTC (permalink / raw)
  To: cygwin

On 14/10/2015 19:27, Andrey Repin wrote:
> Greetings, Adam Dinwoodie!
>> 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.
> If my opinion matters, I would advocate making scripts POSIX compliant, unless
> there's strong reason to explicitly require shell-dependent functionality.

The script is fundamentally dependent on Bash features -- it's binding 
keys in the Bash interactive shell -- and cannot be made POSIX compliant.

It's also part of the fzf project, and making extensive changes like 
that as part of packaging someone else's code seems to rather negate the 
point in doing the packaging.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

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

* Re: [Attn: base-files maintainer] Changing /etc/profile to add more shell-dependent settings
  2015-10-14 17:14   ` Adam Dinwoodie
  2015-10-14 18:35     ` Andrey Repin
@ 2015-10-14 20:15     ` Achim Gratz
  1 sibling, 0 replies; 9+ messages in thread
From: Achim Gratz @ 2015-10-14 20:15 UTC (permalink / raw)
  To: cygwin

Adam Dinwoodie writes:
> 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
> /etc/profile.

Sourcing that script would actually belong into /etc/bash.bashrc if I
understand correctly what this is supposed to do.  Unfortunaltely there
is no infrastructure set up to do this yet in bash.bashrc and simply
changing the file makes it non-upgradeable.  OTOH what I see there on my
Linux system is far too complicated for Cygwin, I'll have to think about
this some more.

> (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.)

No, that should indeed be left to the user.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

SD adaptations for Waldorf Q V3.00R3 and Q+ V3.54R2:
http://Synth.Stromeko.net/Downloads.html#WaldorfSDada

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

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

end of thread, other threads:[~2015-10-14 20:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-14 15:53 [Attn: base-files maintainer] Changing /etc/profile to add more shell-dependent settings Adam Dinwoodie
2015-10-14 16:20 ` Andrey Repin
2015-10-14 16:20 ` Yaakov Selkowitz
2015-10-14 16:32   ` Adam Dinwoodie
2015-10-14 16:53 ` Achim Gratz
2015-10-14 17:14   ` Adam Dinwoodie
2015-10-14 18:35     ` Andrey Repin
2015-10-14 18:49       ` Adam Dinwoodie
2015-10-14 20:15     ` Achim Gratz

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 read-only IMAP folder(s) and NNTP newsgroup(s).