Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Command != command ???



From: Philippe Troin <phil@xxxxxxxx>
Subject: Re: Command != command ???
Date: 24 Jul 2005 21:14:46 -0700

Hi,

 The Tao of ZSH

 First Mantra

 the novice once asked the master guru: "Why are my scripts not
 executed though they are well designed?"

 The master guru only wrotes down a few words only.

 Then the novice was enlighted.

 ----

 Sometimes only a few well formed words in a simple mail are worth a
 lot more than The Stories of One Thousand and one arabian Nights of
 zshall. 

 Thanks so much, Philippe!  :O)

 (Could you please do the same miracle with the completion system ? ;)

 Happy zshing!
 Novice
  Meino

> Meino Christian Cramer <Meino.Cramer@xxxxxx> writes:
> 
> > I am a little confused here -- seems that what I believed to know
> > previously is wrong...
> > 
> > ...I am booting my linux box directly into an X-Server with a kdm
> > login...The shell I start then is...interactively, right? .zshrc
> > setopts my extendedglob...then I start a script from there...which
> > again is not interactively...and will "loose" some features I set in
> > my .zshrc...
> > 
> > Is this correct?
> 
> No, when you start a zsh script (A) from a zsh "interactive session"
> shell (B), A starts completely anew.  The only thing inherited from B
> by A are the environment variables and some other irrelevant state
> (opened file descriptors, limits, etc).  All the rest (options, etc)
> is lost.
> 
> > Is there a list where I can identify those features, which are not
> > valid for scripts, if set in .zshrc? Or do I have to read through the
> > whole zshall manpage?
> 
> In a nutshell:
> 
>   zshenv is always read in all non-pathological cases
> 
>   zprofile is read if your shell is a login shell
> 
>   zshrc is read if your shell is interactive
> 
>   zlogin is read if your shell is a login shell
> 
> So zprofile and zlogin are equivalent except for the sourcing order
> (if one is read, the other is read too).
> 
> We have four combinations:
> 
>   login and interactive: this is the case when logging in through
>   telnet, ssh, and sometimes for shells started by X terminal
>   emulators (depending on your settings);
> 
>   login and non-interactive: I've only seen it used by some display
>   managers when you login (most recent gdm/kdm versions do that, as
>   well as CDE);
> 
>   non-login interactive: eg. a sub-shell, opened by zsh itself or from
>   vi, screen, etc;
> 
>   non-login and non-interactive: scripts.
> 
> I myself use .zshenv, .zprofile and .zshrc this way:
> 
>   In .zshenv, I put: 
> 
>       environment variables definitions: bracketed by an if statement,
>       and only executed if SOME_VARIABLE is unset.  SOME_VARIABLE is
>       set at the end of zshenv);
> 
>       some kind of aliases or autoloads: For example ll='ls -l',
>       because I want to use ll like this some times: 'ssh machine ll
>       /some/dir';
> 
>       all the options that are not relevant to interactive use but
>       which I may use via 'ssh machine command' (eg. rc_quotes,
>       magicequalsubst, etc).
> 
>   In .zprofile, I do once-a-time initialization (eg. run under
>   ssh-agent if not already), terminal initialization, limits settings,
>   everything that's inherited from process to sub-process.
> 
>   Finally .zshrc takes care of: completions, zle and keyboard
>   settings, prompts, and interactive setopts and autoloads.
> 
> Phil.
> 



Messages sorted by: Reverse Date, Date, Thread, Author