zsh-users
 help / color / mirror / code / Atom feed
* Functions in system init scripts
@ 2008-10-17 20:17 Daniel Qarras
  2008-10-17 21:10 ` Jan Hülsbergen
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Qarras @ 2008-10-17 20:17 UTC (permalink / raw)
  To: zsh-users

Hi all,

I guess this an age old problem but it bit me again after few years hiatus. Probably most compactly described by this screenshot from gnome-terminal:

localhost:~> cat /etc/profile.d/functest.sh
functest ()
{
  echo function functest defined
}
FUNCVAR=1
export FUNCVAR
localhost:~> echo $FUNCVAR
1
localhost:~> which functest
functest not found
zsh: exit 1
localhost:~> . /etc/profile.d/functest.sh
localhost:~> which functest              
functest () {
	echo function functest defined
}

What happens here is that some applications install their initialization scripts under /etc/profile.d and those get sourced via /etc/profile when a user logins (and /etc/profile is sourced by /etc/zprofile). With console sessions or ssh connections all is good.

When a user is logging via a display manager like GDM, the function definitions get "lost" as only zshenv/.zshenv/zshrc/.zshrc are getting sourced when an xterm / gnome-terminal is launched. zprofile/.zprofile are sourced during the login but only environment variable setting survive till xterm/gnome-terminal.

So the question is what would be the most optimal way to fix this? Some distributions' zsh package (e.g., Red Hat's) actually source init scripts under /etc/profile.d *twice* but that raises new problems as then a user will have hard time to override some settings in his own init scripts (and it just feel broken to do something like that twice in any case).

Thanks!



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


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

* Re: Functions in system init scripts
  2008-10-17 20:17 Functions in system init scripts Daniel Qarras
@ 2008-10-17 21:10 ` Jan Hülsbergen
  2008-10-19 18:10   ` Daniel Qarras
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Hülsbergen @ 2008-10-17 21:10 UTC (permalink / raw)
  To: dqarras; +Cc: zsh-users

Hi Daniel,

On Fri, Oct 17, 2008 at 22:17, Daniel Qarras <dqarras@yahoo.com> wrote:
> What happens here is that some applications install their initialization scripts under /etc/profile.d and those get sourced via /etc/profile when a user logins (and /etc/profile is sourced by /etc/zprofile). With console sessions or ssh connections all is good.
>
> When a user is logging via a display manager like GDM, the function definitions get "lost" as only zshenv/.zshenv/zshrc/.zshrc are getting sourced when an xterm / gnome-terminal is launched. zprofile/.zprofile are sourced during the login but only environment variable setting survive till xterm/gnome-terminal.
>
> So the question is what would be the most optimal way to fix this? Some distributions' zsh package (e.g., Red Hat's) actually source init scripts under /etc/profile.d *twice* but that raises new problems as then a user will have hard time to override some settings in his own init scripts (and it just feel broken to do something like that twice in any case).

One way to fix this is to make your terminal emulator execute the
shells as login shells (gnome-terminal can do that IIRC).

Another way would be to *only* source /etc/profile in your zshrc as
this file gets executed for any interactive shell, login or not.

HTH
Jan


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

* Re: Functions in system init scripts
  2008-10-17 21:10 ` Jan Hülsbergen
@ 2008-10-19 18:10   ` Daniel Qarras
  2008-10-19 18:42     ` Clint Adams
  2008-10-19 21:10     ` Bart Schaefer
  0 siblings, 2 replies; 5+ messages in thread
From: Daniel Qarras @ 2008-10-19 18:10 UTC (permalink / raw)
  To: zsh-users

Hi!

> > When a user is logging via a display manager like GDM,
> the function definitions get "lost" as only
> zshenv/.zshenv/zshrc/.zshrc are getting sourced when an
> xterm / gnome-terminal is launched. zprofile/.zprofile are
> sourced during the login but only environment variable
> setting survive till xterm/gnome-terminal.
> 
> One way to fix this is to make your terminal emulator
> execute the shells as login shells (gnome-terminal can do that IIRC).

True, thanks for the tip (although this doesn't sound optimal as xterm would still be unfixed).

> Another way would be to *only* source /etc/profile in your
> zshrc as this file gets executed for any interactive shell, login
> or not.

Yeah, I guess this is more or less the only option; the side-effect is that one needs to move stuff from zprofile/.zprofile to zshrc/.zshrc in order to be able to override system settings (e.g., locale settings). This is perhaps bit contradicting of how many view the division between different zsh init files.

Cheers!



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


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

* Re: Functions in system init scripts
  2008-10-19 18:10   ` Daniel Qarras
@ 2008-10-19 18:42     ` Clint Adams
  2008-10-19 21:10     ` Bart Schaefer
  1 sibling, 0 replies; 5+ messages in thread
From: Clint Adams @ 2008-10-19 18:42 UTC (permalink / raw)
  To: Daniel Qarras; +Cc: zsh-users

On Sun, Oct 19, 2008 at 11:10:31AM -0700, Daniel Qarras wrote:
> True, thanks for the tip (although this doesn't sound optimal as xterm would still be unfixed).

You can cause xterm to launch login shells either by command-line switch
or by X resource.


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

* Re: Functions in system init scripts
  2008-10-19 18:10   ` Daniel Qarras
  2008-10-19 18:42     ` Clint Adams
@ 2008-10-19 21:10     ` Bart Schaefer
  1 sibling, 0 replies; 5+ messages in thread
From: Bart Schaefer @ 2008-10-19 21:10 UTC (permalink / raw)
  To: zsh-users

On Oct 19, 11:10am, Daniel Qarras wrote:
}
} > One way to fix this is to make your terminal emulator
} > execute the shells as login shells (gnome-terminal can do that IIRC).
} 
} True, thanks for the tip (although this doesn't sound optimal as xterm
} would still be unfixed).

You can also put something like this in your ~/.zshenv file:

# Force most interactive shells to be login shells
[[ -t 0 && -o interactive && -o shinstdin ]] && setopt login

You can add a test for various values of $TERM, etc., as needed.


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

end of thread, other threads:[~2008-10-19 21:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-17 20:17 Functions in system init scripts Daniel Qarras
2008-10-17 21:10 ` Jan Hülsbergen
2008-10-19 18:10   ` Daniel Qarras
2008-10-19 18:42     ` Clint Adams
2008-10-19 21:10     ` Bart Schaefer

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