zsh-users
 help / color / mirror / code / Atom feed
* strange behaviour with .zsh and su
@ 1997-04-14 14:32 Louis-David Mitterrand
  1997-04-14 15:06 ` Zefram
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Louis-David Mitterrand @ 1997-04-14 14:32 UTC (permalink / raw)
  To: zsh-users

I recently switched to defining a ZSHDOTDIR in /etc/zprofile to
unclutter my home directory. It works fine when I am logged as a normal
user but now when I 'su' to root from that account root's .zshrc isn't
sourced anymore even though I put root's .zshrc into its own ZDOTDIR...

When I 'su -l' the .zsh/.zshrc is sourced but I'd rather it worked with
plain 'su' so that I don't change directories. 

Am I doing something wrong?

config:

Linux, zsh_3.0.3

export ZSHDOTDIR=.zsh

TIA

-- 

     Louis-David Mitterrand
     http://www.aparima.com/F1/
     mito@aparima.com


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

* Re: strange behaviour with .zsh and su
  1997-04-14 14:32 strange behaviour with .zsh and su Louis-David Mitterrand
@ 1997-04-14 15:06 ` Zefram
  1997-04-14 15:47 ` Timothy Luoma
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 13+ messages in thread
From: Zefram @ 1997-04-14 15:06 UTC (permalink / raw)
  To: mito; +Cc: zsh-users

Louis-David Mitterrand wrote:
>export ZSHDOTDIR=.zsh

Perhaps you want

export ZDOTDIR=~/.zsh

but in any case this isn't going to work over an su as you can't have
two users' startup files in the same place.  I suggest you abandon it
and just put the startup files in users' home directories.

-zefram


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

* Re: strange behaviour with .zsh and su
  1997-04-14 14:32 strange behaviour with .zsh and su Louis-David Mitterrand
  1997-04-14 15:06 ` Zefram
@ 1997-04-14 15:47 ` Timothy Luoma
  1997-04-14 15:48   ` Louis-David Mitterrand
  1997-04-14 18:20   ` Stefan Monnier
  1997-04-14 16:02 ` gwing
  1997-04-14 17:03 ` Stefan Monnier
  3 siblings, 2 replies; 13+ messages in thread
From: Timothy Luoma @ 1997-04-14 15:47 UTC (permalink / raw)
  To: mito; +Cc: zsh-users


I have had much success with putting just a .zshenv file in my $HOME with
some basic information, including a ZSH folder (which, in my case is
$HOME/Unix/zsh/).

The zshenv file includes a loop which sources any file found in
$HOME/Unix/zsh/source, so I have several files in there:

aliases
bindkeys
functions

The advantage is that I have all my aliases in one file, all my bindkeys
in another, etc etc and I can easily check/change them.  An error in my
alises file does not prevent my bindkeys and functions from being loaded,
etc etc.

I feel that this is a good solution, it works for 'su' just fine, and I
still only have one entry in my $HOME (.zshenv) and can put the other
zsh-related files in another nested folder.

TjL





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

* Re: strange behaviour with .zsh and su
  1997-04-14 15:47 ` Timothy Luoma
@ 1997-04-14 15:48   ` Louis-David Mitterrand
  1997-04-14 16:01     ` Timothy Luoma
  1997-04-14 18:20   ` Stefan Monnier
  1 sibling, 1 reply; 13+ messages in thread
From: Louis-David Mitterrand @ 1997-04-14 15:48 UTC (permalink / raw)
  To: zsh-users

On Apr 14 97, Timothy Luoma <luomat@peak.org> wrote:
> 
> I have had much success with putting just a .zshenv file in my $HOME with
> some basic information, including a ZSH folder (which, in my case is
> $HOME/Unix/zsh/).
> 
> The zshenv file includes a loop which sources any file found in
> $HOME/Unix/zsh/source, so I have several files in there:
> 
> aliases
> bindkeys
> functions

That would be an elegant solution to my .zshrc's uncontrolable inflation
;-)

> The advantage is that I have all my aliases in one file, all my bindkeys
> in another, etc etc and I can easily check/change them.  An error in my
> alises file does not prevent my bindkeys and functions from being loaded,
> etc etc.
> 
> I feel that this is a good solution, it works for 'su' just fine, and I
> still only have one entry in my $HOME (.zshenv) and can put the other
> zsh-related files in another nested folder.

One question: dosen't putting your init commmands in a .zshenv guarantee
that these init files will be sourced on *every* invocation of zsh, even
non-interactive ones? Is it not preferable to have these files sourced
only if the shell is interactive?

Thanks.

-- 

     Louis-David Mitterrand
     http://www.aparima.com/F1/
     mito@aparima.com


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

* Re: strange behaviour with .zsh and su
  1997-04-14 15:48   ` Louis-David Mitterrand
@ 1997-04-14 16:01     ` Timothy Luoma
  1997-04-14 16:14       ` Louis-David Mitterrand
  0 siblings, 1 reply; 13+ messages in thread
From: Timothy Luoma @ 1997-04-14 16:01 UTC (permalink / raw)
  To: mito; +Cc: zsh-users


> One question: dosen't putting your init commmands in a .zshenv guarantee
> that these init files will be sourced on *every* invocation of zsh, even
> non-interactive ones? Is it not preferable to have these files sourced
> only if the shell is interactive?

that would be a bad thing, of course.

ZSH has a workaround.  Put whatever you want only for interactive inside
this:

if [[ -o interactive ]]                 # if an interactive shell
then


fi


TjL


-- 
TjL   <luomat@peak.org>   http://www.peak.org/~luomat/next/ 
"Give a man a piece of working code and you solve his problem.
 Teach a man to write code and you give him a 
 lifetime of new problems"	-- me
 
 



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

* Re: strange behaviour with .zsh and su
  1997-04-14 14:32 strange behaviour with .zsh and su Louis-David Mitterrand
  1997-04-14 15:06 ` Zefram
  1997-04-14 15:47 ` Timothy Luoma
@ 1997-04-14 16:02 ` gwing
  1997-04-14 17:03 ` Stefan Monnier
  3 siblings, 0 replies; 13+ messages in thread
From: gwing @ 1997-04-14 16:02 UTC (permalink / raw)
  To: zsh-users; +Cc: mito

Louis-David Mitterrand wrote:
In zsh.users you write:
:I recently switched to defining a ZSHDOTDIR in /etc/zprofile to
:unclutter my home directory. It works fine when I am logged as a normal
:user but now when I 'su' to root from that account root's .zshrc isn't
:sourced anymore even though I put root's .zshrc into its own ZDOTDIR...
:When I 'su -l' the .zsh/.zshrc is sourced but I'd rather it worked with
:plain 'su' so that I don't change directories.
:Linux, zsh_3.0.3
:export ZSHDOTDIR=.zsh

1. I hope you are using ZDOTDIR, not ZSHDOTDIR
2. /etc/zprofile isn't sourced unless you're in a login shell.  Put your
   ZDOTDIR stuff in /etc/zshenv - that's the only file that can be guaranteed
   to be read for each instance.

I don't understand your full situation.  Eg. where do your startup files
reside and where do root's?  You seem to be implying that if you're in a 
directory, say /foo , then when you su the startup files are in
/foo/.zsh  but if you cd to /bar  then when you su the startup files
are in /bar/.zsh
Is this right?  If not, please clarify the situation.
-- 
Geoff Wing [mason@primenet.com.au]   Technical Manager
  Phone    : +61-3-9818 2977         PrimeNet - Internet Consultancy
  Facsimile: +61-3-9819 3788         Web : <URL:http://www.primenet.com.au/>
  Mobile   : 0412 162 441


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

* Re: strange behaviour with .zsh and su
  1997-04-14 16:01     ` Timothy Luoma
@ 1997-04-14 16:14       ` Louis-David Mitterrand
       [not found]         ` <mito@aparima.com>
  0 siblings, 1 reply; 13+ messages in thread
From: Louis-David Mitterrand @ 1997-04-14 16:14 UTC (permalink / raw)
  To: zsh-users

On Apr 14 97, Timothy Luoma <luomat@peak.org> wrote:
> 
> ZSH has a workaround.  Put whatever you want only for interactive inside
> this:
> 
> if [[ -o interactive ]]                 # if an interactive shell
> then
> 
> fi

That's good and useful to know. Thanks.

On Apr 15 97, gwing@primenet.com.au <gwing@primenet.com.au> wrote:
> 1. I hope you are using ZDOTDIR, not ZSHDOTDIR

ZDOTDIR actually, sorry for the typo.

> 2. /etc/zprofile isn't sourced unless you're in a login shell.  Put your
>    ZDOTDIR stuff in /etc/zshenv - that's the only file that can be guaranteed
>    to be read for each instance.

Yes but when you 'su' shouldn't it be a login shell you land in? (Even
though the full environment isn't present as in 'su -l') If so the
/etc/zprofile should be sourced..

> I don't understand your full situation.  Eg. where do your startup files
> reside and where do root's?  You seem to be implying that if you're in a 

I moved the startup files in $HOME/.zsh for each user (including root).

> directory, say /foo , then when you su the startup files are in
> /foo/.zsh  but if you cd to /bar  then when you su the startup files

You are right, I understand now: my 'ZDOTDIR=.zsh' was wrong, as Zefram
also suggested. The correct entry is 'export ZDOTDIR=~/.zsh'. 

Thanks for your help.
-- 

     Louis-David Mitterrand
     http://www.aparima.com/F1/
     mito@aparima.com


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

* Re: strange behaviour with .zsh and su
       [not found]         ` <mito@aparima.com>
@ 1997-04-14 16:54           ` Bart Schaefer
  0 siblings, 0 replies; 13+ messages in thread
From: Bart Schaefer @ 1997-04-14 16:54 UTC (permalink / raw)
  To: mito, zsh-users

On Apr 14, 12:14pm, Louis-David Mitterrand wrote:
} Subject: Re: strange behaviour with .zsh and su
}
} when you 'su' shouldn't it be a login shell you land in?

No.

-- 
Bart Schaefer                             Brass Lantern Enterprises
http://www.well.com/user/barts            http://www.nbn.com/people/lantern


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

* Re: strange behaviour with .zsh and su
  1997-04-14 14:32 strange behaviour with .zsh and su Louis-David Mitterrand
                   ` (2 preceding siblings ...)
  1997-04-14 16:02 ` gwing
@ 1997-04-14 17:03 ` Stefan Monnier
  3 siblings, 0 replies; 13+ messages in thread
From: Stefan Monnier @ 1997-04-14 17:03 UTC (permalink / raw)
  To: zsh-users

Louis-David Mitterrand <mito@aparima.com> writes:
> user but now when I 'su' to root from that account root's .zshrc isn't
> sourced anymore even though I put root's .zshrc into its own ZDOTDIR...

"su" generally doesn't start the shell as a login shell, so your /etc/zprofile
is not sourced. You probably want to use "su -" instead.


        Stefan


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

* Re: strange behaviour with .zsh and su
  1997-04-14 15:47 ` Timothy Luoma
  1997-04-14 15:48   ` Louis-David Mitterrand
@ 1997-04-14 18:20   ` Stefan Monnier
  1997-04-14 18:32     ` Richard Coleman
  1997-04-14 18:42     ` Tom Howland
  1 sibling, 2 replies; 13+ messages in thread
From: Stefan Monnier @ 1997-04-14 18:20 UTC (permalink / raw)
  To: zsh-users

Timothy Luoma <luomat@peak.org> writes:
> The zshenv file includes a loop which sources any file found in
> $HOME/Unix/zsh/source, so I have several files in there:

I don't know why shell writers insist on using several init files.
The .login/.zshprofile/.zshlogin file isn't sourced every time you'd need it
(typically, it's not sourced from an XDM login), so you need to move stuff from
there into zshenv.

On another hand, a variable indicating whether the shell is a login shell is
necessary (and sadly missing from tcsh).


        Stefan


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

* Re: strange behaviour with .zsh and su
  1997-04-14 18:20   ` Stefan Monnier
@ 1997-04-14 18:32     ` Richard Coleman
  1997-04-14 20:27       ` Stefan Monnier
  1997-04-14 18:42     ` Tom Howland
  1 sibling, 1 reply; 13+ messages in thread
From: Richard Coleman @ 1997-04-14 18:32 UTC (permalink / raw)
  To: zsh-users

> Timothy Luoma <luomat@peak.org> writes:
> > The zshenv file includes a loop which sources any file found in
> > $HOME/Unix/zsh/source, so I have several files in there:
> 
> I don't know why shell writers insist on using several init files.
> The .login/.zshprofile/.zshlogin file isn't sourced every time you'd need it
> (typically, it's not sourced from an XDM login), so you need to move stuff from
> there into zshenv.
> 
> On another hand, a variable indicating whether the shell is a login shell is
> necessary (and sadly missing from tcsh).

I think zsh's method for startup files is the most logical
of all the common shells.

.zshenv  -- invoked on every startup
.zshrc   -- invoked for interactive shells
.zlogin  -- invoked for login shells
.zlogout -- invoked on logout

This give you complete flexibility.  I wouldn't want all
that stuff in a single file.  Of course you need to might
sure things are in the right file, but you only need to
do that once.

rc


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

* Re: strange behaviour with .zsh and su
  1997-04-14 18:20   ` Stefan Monnier
  1997-04-14 18:32     ` Richard Coleman
@ 1997-04-14 18:42     ` Tom Howland
  1 sibling, 0 replies; 13+ messages in thread
From: Tom Howland @ 1997-04-14 18:42 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: zsh-users

Stefan Monnier writes:
 > Timothy Luoma <luomat@peak.org> writes:
 > > The zshenv file includes a loop which sources any file found in
 > > $HOME/Unix/zsh/source, so I have several files in there:
 >
 > I don't know why shell writers insist on using several init files.
 > The .login/.zshprofile/.zshlogin file isn't sourced every time you'd need it
 > (typically, it's not sourced from an XDM login), so you need to move stuff from
 > there into zshenv.

I agree. There are already plenty of initialization files for zsh.

 > On another hand, a variable indicating whether the shell is a login shell is
 > necessary (and sadly missing from tcsh).

Its not all that necessary. The following seems to work

tty -s
[ $? -eq 0 ] && stty -parenb -istrip cs8 erase "^H" intr "^C" susp "^Z" start "^Q" stop "^S" quit "^\\" dsusp "^Y" -ixany echoe


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

* Re: strange behaviour with .zsh and su
  1997-04-14 18:32     ` Richard Coleman
@ 1997-04-14 20:27       ` Stefan Monnier
  0 siblings, 0 replies; 13+ messages in thread
From: Stefan Monnier @ 1997-04-14 20:27 UTC (permalink / raw)
  To: zsh-users

Richard Coleman <coleman@math.gatech.edu> writes:
> I think zsh's method for startup files is the most logical
> of all the common shells.
> .
> .zshenv  -- invoked on every startup.
> .zshrc   -- invoked for interactive shells.
> .zlogin  -- invoked for login shells.
> .zlogout -- invoked on logout

If it is the most logical for you, it's fine. But if it isn't, it does all
those lookups for no reason. Actually, I don't care so much, I don't have to
use them, right ? (my .zprofile and .zlogin are always empty since I mostly
login via XDM anyway)

The problem is more with /etc/zprofile and /etc/zlogin since you have to be
careful with what you put in there: it might very well break (be broken by)
..zshenv (and even .zprofile and .zshrc for the /etc/zlogin).

I'd be perfectly happy with

        /etc/zshenv, /etc/zshrc, ~/.zshenv, ~/.zshrc

This way there is no weird interaction between user's and system's files.

Anyway, this is all hot-air because it's not going to change any time soon,


        Stefan


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

end of thread, other threads:[~1997-04-14 20:32 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-04-14 14:32 strange behaviour with .zsh and su Louis-David Mitterrand
1997-04-14 15:06 ` Zefram
1997-04-14 15:47 ` Timothy Luoma
1997-04-14 15:48   ` Louis-David Mitterrand
1997-04-14 16:01     ` Timothy Luoma
1997-04-14 16:14       ` Louis-David Mitterrand
     [not found]         ` <mito@aparima.com>
1997-04-14 16:54           ` Bart Schaefer
1997-04-14 18:20   ` Stefan Monnier
1997-04-14 18:32     ` Richard Coleman
1997-04-14 20:27       ` Stefan Monnier
1997-04-14 18:42     ` Tom Howland
1997-04-14 16:02 ` gwing
1997-04-14 17:03 ` Stefan Monnier

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