From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 735 invoked from network); 9 Aug 1998 20:03:02 -0000 Received: from ns2.primenet.com.au (HELO primenet.com.au) (7795@203.24.36.3) by ns1.primenet.com.au with SMTP; 9 Aug 1998 20:03:02 -0000 Received: (qmail 4765 invoked from network); 9 Aug 1998 19:12:28 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns2.primenet.com.au with SMTP; 9 Aug 1998 19:12:28 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id PAA01251; Sun, 9 Aug 1998 15:03:33 -0400 (EDT) Resent-Date: Sun, 9 Aug 1998 15:03:24 -0400 (EDT) Message-ID: <19980809150805.47993@astaroth.nit.gwu.edu> Date: Sun, 9 Aug 1998 15:08:05 -0400 From: Sweth Chandramouli To: ZSH Users Subject: init files Mail-Followup-To: ZSH Users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=bg08WKrSYDhXBjb5 X-Mailer: Mutt 0.89 Resent-Message-ID: <"5rTEg3.0.3J.x9Vpr"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1713 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu --bg08WKrSYDhXBjb5 Content-Type: text/plain; charset=us-ascii okay, i've been playing around with the init files that zsh uses, trying to figure out which ones get invoked when, and i think i've got it all mostly worked out; the flowchart i've made is attached to this message. i still have some questions, though. there was a thread about this maybe a year ago, wherein bart (i think) had said that the NO_RCS option was checked before the sourcing of /etc/zshrc and $ZDOTDIR/.zshrc; no matter what i've tried, however, i've been unable to to reproduce this (which my chart reflects). also, i'm not perfectly clear on what tests are done to determine whether or not a shell is a login shell and/or an interactive one. i've got those tests that i've been able to confirm empirically listed in the footnotes on my chart, but i'm sure that there are others. at the very least, the man pages state that INTERACTIVE can be set to a different value, whereas whenever i try to do so, i get an error back; similarly, the tests given in the STARTUP FILES section of the manpage for a login shell (-l or -zsh) aren't true for any of my login shells, but they are still recognized as such. so which are the tests that i'm missing? -- sweth. -- Sweth Chandramouli IS Coordinator, The George Washington University / (202) 994 - 8521 (V) / (202) 994 - 0458 (F) * --bg08WKrSYDhXBjb5 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=zshinits ZSH initialization file load sequence: | {/etc/zshenv} | | | (is NO_RCS set?[1]) | | [yes] | [no] ---------------------------------- | | | | | {$ZDOTDIR/.zshenv} | | | | (is this a login shell?[2]) | | | [yes] | [no] | ------------------------------- | | | | {/etc/zprofile} | | | | (is this shell | {$ZDOTDIR/.zprofile} | interactive?[3]) | | | | | [yes] | [no] | | ------------------- | | | | | {/etc/zshrc} {/etc/zshrc} | | | | | | {$ZDOTDIR/.zshrc} {$ZDOTDIR/.zshrc} | | | | | | | | | | {/etc/zlogin} | | | | | | | {$ZDOTDIR/.zlogin} | | | | | | | | | | **************************************************************** * SHELL * **************************************************************** | | | | | | (is NO_RCS | | | | set?[1]) | | | | | | | [yes] | [no] | | | ------------------- | | | | | | | | | {$ZDOTDIR/.zlogout} | | | | | | | | | {/etc/zlogout} | | | | | | | x x x x x Tests are matched as follows, in increasing order of precedence; `unsetopt OPTION' is equivalent to `setopt NO_OPTION' and `unsetopt NO_OPTION' is equivalent to `setopt OPTION' in terms of precedence. For example, zsh -f with `unsetopt NO_RCS' in /etc/zshenv will source /etc/zshenv, $ZDOTDIR/.zshenv, /etc/zshrc, and $ZDOTDIR/.zshrc. [1] DEFAULT => [no] `setopt NO_RCS' called before test => [yes] `-f' flag present on shell invocation => [yes] `setopt RCS' called before test => [no] [2] DEFAULT => [no] first character of argument zero (name by which zsh is invoked) is `-' => [yes] `-l' flag present on shell invocation => [yes] [3] DEFAULT => [no] `-i' flag present on shell invocation => [yes] standard input is a tty and commands are being read from standard input => [yes] --bg08WKrSYDhXBjb5-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2063 invoked from network); 9 Aug 1998 22:15:06 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 9 Aug 1998 22:15:06 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id SAA02926; Sun, 9 Aug 1998 18:02:38 -0400 (EDT) Resent-Date: Sun, 9 Aug 1998 18:02:27 -0400 (EDT) From: "Bart Schaefer" Message-Id: <980809150442.ZM21544@candle.brasslantern.com> Date: Sun, 9 Aug 1998 15:04:41 -0700 In-Reply-To: <19980809150805.47993@astaroth.nit.gwu.edu> Comments: In reply to Sweth Chandramouli "init files" (Aug 9, 3:08pm) References: <19980809150805.47993@astaroth.nit.gwu.edu> X-Mailer: Z-Mail (4.0b.820 20aug96) To: Sweth Chandramouli , ZSH Users Subject: Re: init files MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"-7K2R1.0.8j.onXpr"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1714 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu On Aug 9, 3:08pm, Sweth Chandramouli wrote: } Subject: init files } } there was a thread about this maybe a year ago, wherein bart (i } think) had said that the NO_RCS option was checked before the } sourcing of /etc/zshrc and $ZDOTDIR/.zshrc Yes, I did say that, but Greg Badros pointed out that I should have said that INTERACTIVE was tested, not NO_RCS. He included a pointer to a flow chart: http://www.cs.washington.edu/homes/gjb/ToolsTalks/unix-shell/img009.GIF } also, i'm not perfectly clear on what tests } are done to determine whether or not a shell is a login shell The only test done is whether the LOGIN option is set. This option may be set (or unset) explicitly with setopt (unsetopt) or -l (+l), and is otherwise set only if the first character of argv[0] is '-'. } and/or an interactive one. INTERACTIVE is set when isatty(0) is true, and is unset again if the -c option or the name of a script file is provided, unless -i is also given. Of course, it's also unset by the +i option. } at the very least, the man } pages state that INTERACTIVE can be set to a different value, } whereas whenever i try to do so, i get an error back Where do you find that in the man page? My "man zshoptions" under INTERACTIVE says, "The value of this option cannot be changed anywhere other than the command line." } the tests given in the STARTUP FILES section of the manpage } for a login shell (-l or -zsh) aren't true for any of my login } shells How are you determining this? What does "echo $0" at a PS1 prompt show? -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3856 invoked from network); 10 Aug 1998 01:15:28 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 10 Aug 1998 01:15:28 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id UAA04031; Sun, 9 Aug 1998 20:57:32 -0400 (EDT) Resent-Date: Sun, 9 Aug 1998 20:57:22 -0400 (EDT) Message-ID: <19980809210204.33286@astaroth.nit.gwu.edu> Date: Sun, 9 Aug 1998 21:02:04 -0400 From: Sweth Chandramouli To: ZSH Users Subject: Re: Re: init files Mail-Followup-To: ZSH Users References: <19980809150805.47993@astaroth.nit.gwu.edu> <980809150442.ZM21544@candle.brasslantern.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.89 In-Reply-To: <980809150442.ZM21544@candle.brasslantern.com> Resent-Message-ID: <"s08-92.0.V-.nLapr"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1715 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu On Sun, Aug 09, 1998 at 03:04:41PM -0700, Bart Schaefer wrote: > On Aug 9, 3:08pm, Sweth Chandramouli wrote: > Yes, I did say that, but Greg Badros pointed > out that I should have said that INTERACTIVE was tested, not NO_RCS. > He included a pointer to a flow chart: > > http://www.cs.washington.edu/homes/gjb/ToolsTalks/unix-shell/img009.GIF hmm... i've actually still got both of those messages archived, and i don't find INTERACTIVE mentioned in either. [snip] > Where do you find that in the man page? My "man zshoptions" under > INTERACTIVE says, "The value of this option cannot be changed anywhere > other than the command line." > > } the tests given in the STARTUP FILES section of the manpage > } for a login shell (-l or -zsh) aren't true for any of my login > } shells > > How are you determining this? What does "echo $0" at a PS1 prompt show? that i need to read the manpages better. i totally misread the part about changing interactive (too many hours staring at a screen, i guess), and my shell is defined as a login one because its argv[0] is `-zsh'. i assumed it didn't because of the info in the faq on changing your shell, which mentioned linking it to -zsh; echo $0 shows that i am running -zsh, even though i never made that link. does login somehow invoke the shell and pass it a modified argv[0]? regardless, here is my revised list of tests for the sourcing of the various rc files. i'm not including the chart itself--it's at http://astaroth.nit.gwu.edu/~sweth/geek/zshinit.html if people want to see it; for those who don't, test one returns [no] if rc files are enabled, test two returns [no] if the shell isn't a login shell, and test three returns [no] if the shell isn't interactive. so, do these look right, or am i missing anything else? also, while figuring all of these out, a few things occurred to me. for one, does it make sense for the precedence of `unsetopt RCS' to be different from that of `setopt RCS' in test one? everywhere else, the inversions of options seem to have the same precedence as each other. secondly, is there any way to ensure that an action will be taken for all users upon logout? since test one is repeated just before sourcing $ZDOTDIR/.zlogout and /etc/zlogout, any user can just put `set NO_RCS' in his/her $ZDOTDIR/.zlogin, which is the last RC to be sourced, and avoid sourcing /etc/zlogout. finally, what is the purpose of the `+i' flag? `zsh +i' doesn't spawn a non-interactive shell (which would, i would imagine, immediately exit without some source of input), but instead spawns a shell where the only option set is SHIN_STDIN, but which is still interactive (and which ignores PROMPT, it seems). -- sweth. ----- `unsetopt OPTION' is equivalent to `setopt NO_OPTION' and `unsetopt NO_OPTION' is equivalent to `setopt OPTION' in terms of precedence. For example, zsh -f with `unsetopt NO_RCS' in /etc/zshenv will source /etc/zshenv, $ZDOTDIR/.zshenv, /etc/zshrc, and $ZDOTDIR/.zshrc. [1] DEFAULT--rc-enabled shell => [no] `setopt NO_RCS' called before test => [yes] `+f' flag present on shell invocation => [no] `-f' flag present on shell invocation => [yes] `setopt RCS' called before test => [no] [2] DEFAULT--non-login shell => [no] first character of argv[0] is `-' => [yes] `+l' flag present on shell invocation => [no] `-l' flag present on shell invocation => [yes] `setopt NO_LOGIN' called before test => [no] `setopt LOGIN' called before test => [yes] [3] DEFAULT--non-interactive shell => [no] stdin is a tty (isatty(0) is true) => [yes] `-c' flag present on shell invocation => [no] `-s' flag present on shell invocation => [yes] `+s' flag present on shell invocation => [no] `-i' flag present on shell invocation => [yes] `+i' flag present on shell invocation => [no] -- Sweth Chandramouli IS Coordinator, The George Washington University / (202) 994 - 8521 (V) / (202) 994 - 0458 (F) * From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5615 invoked from network); 10 Aug 1998 04:00:30 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 10 Aug 1998 04:00:30 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id XAA05264; Sun, 9 Aug 1998 23:49:02 -0400 (EDT) Resent-Date: Sun, 9 Aug 1998 23:48:52 -0400 (EDT) From: "Bart Schaefer" Message-Id: <980809205100.ZM24722@candle.brasslantern.com> Date: Sun, 9 Aug 1998 20:51:00 -0700 In-Reply-To: <19980809210204.33286@astaroth.nit.gwu.edu> Comments: In reply to Sweth Chandramouli "Re: Re: init files" (Aug 9, 9:02pm) References: <19980809150805.47993@astaroth.nit.gwu.edu> <980809150442.ZM21544@candle.brasslantern.com> <19980809210204.33286@astaroth.nit.gwu.edu> X-Mailer: Z-Mail (4.0b.820 20aug96) To: Sweth Chandramouli , ZSH Users Subject: Re: init files MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"LDgRM3.0.mH1.Zscpr"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1716 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu On Aug 9, 9:02pm, Sweth Chandramouli wrote: } Subject: Re: Re: init files } } regardless, here is my revised list of tests for the sourcing of } the various rc files. [...] do these look right, or } am i missing anything else? They're all more complicated than they need to be. The tests zsh does are very simple: [1] Is RCS unset? [2] Is LOGIN set? [3] Is INTERACTIVE set? Everything else you include in your lists simply determines the state of those three options. } for one, does it make sense for the precedence of `unsetopt RCS' to be } different from that of `setopt RCS' in test one? everywhere else, the } inversions of options seem to have the same precedence as each other. I don't quite understand what you mean by "precedence." Any setopt or unsetopt that happens in /etc/zshenv can change the command line options, except for -i/+i. The command line options can change the defaults or the values determined by tests like isatty(0). That's all there is. If you mean that the lists under each of your test numbers are supposed to be in some sort of order, then you have the order wrong. [1] DEFAULT--rc-enabled shell => RCS unless `-f' flag present on shell invocation => NO_RCS unless `+f' flag present on shell invocation => RCS unless ( `unsetopt RCS' called in /etc/zshenv => NO_RCS or `setopt RCS' called in /etc/zshenv => RCS ) [2] DEFAULT--non-login shell => NO_LOGIN unless first character of argv[0] is `-' => LOGIN unless ( `+l' flag present on shell invocation => NO_LOGIN or `-l' flag present on shell invocation => LOGIN ) unless ( `unsetopt LOGIN' called before test => NO_LOGIN or `setopt LOGIN' called before test => LOGIN ) [3] DEFAULT--non-interactive shell => NO_INTERACTIVE unless stdin is a tty (isatty(0) is true) => INTERACTIVE unless script name present on shell invocation => NO_INTERACTIVE unless `-s' flag present on shell invocation => INTERACTIVE *and* stdin is a tty unless `-c' flag present on shell invocation => NO_INTERACTIVE unless ( `-i' flag present on shell invocation => INTERACTIVE or `+i' flag present on shell invocation => NO_INTERACTIVE ) Note that there are two "oddities" here: First, +f always wins over -f when both appear, no matter in what order; for all the other flags, whichever one comes last wins. I don't know why this is. Second, +s cannot unset SHINSTDIN when there is no other possible source of input, which is why I listed "script name present" instead of +s. } secondly, is there any way to ensure that an action will be taken for all } users upon logout? Not really; you summed up the situation accurately. } finally, what is the purpose of the `+i' flag? } `zsh +i' doesn't spawn a non-interactive shell (which would, i would } imagine, immediately exit without some source of input), but instead } spawns a shell where the only option set is SHIN_STDIN, but which is } still interactive (and which ignores PROMPT, it seems). You're confusing "interactive" with "reads from the tty." A shell that doesn't prompt is not "interactive." It's reading commands from stdin, and stdin happens to be a tty, but the shell doesn't care. You'll note that it doesn't do other interactive things either, e.g., it ignores the CORRECT option, it won't let you setopt ZLE, and if you type ctrl-Z you suspend the whole shell. As for what the purpose is, well, I can come up with only rather far- fetched examples of cases when you might use it, but it's there just in case. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8090 invoked from network); 10 Aug 1998 09:21:49 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 10 Aug 1998 09:21:49 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id FAA07430; Mon, 10 Aug 1998 05:11:19 -0400 (EDT) Resent-Date: Mon, 10 Aug 1998 05:11:07 -0400 (EDT) Message-Id: <199808100913.KAA28070@diamond.tao.co.uk> Subject: Re: Re: init files To: sweth@astaroth.nit.gwu.edu (Sweth Chandramouli) Date: Mon, 10 Aug 1998 10:13:13 +0100 (BST) From: "Zefram" Cc: zsh-users@math.gatech.edu In-Reply-To: <19980809210204.33286@astaroth.nit.gwu.edu> from "Sweth Chandramouli" at Aug 9, 98 09:02:04 pm X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-ID: <"l05kO3.0.jp1.hahpr"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1717 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Sweth Chandramouli wrote: > i totally misread the part about changing interactive (too many hours >staring at a screen, i guess), and my shell is defined as a login one because >its argv[0] is `-zsh'. i assumed it didn't because of the info in the faq on >changing your shell, which mentioned linking it to -zsh; echo $0 shows that >i am running -zsh, even though i never made that link. does login somehow >invoke the shell and pass it a modified argv[0]? Yes. login always adds the "-" when invoking the user's shell. >secondly, is there any way to ensure that an action will be taken for all >users upon logout? Yes. Modify login to invoke the command when the login shell terminates. Any method based on the user's shell performing the action can be trivially circumvented. -zefram From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26544 invoked from network); 15 Aug 1998 17:36:31 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 15 Aug 1998 17:36:31 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id NAA03001; Sat, 15 Aug 1998 13:22:42 -0400 (EDT) Resent-Date: Sat, 15 Aug 1998 13:22:33 -0400 (EDT) From: "Bart Schaefer" Message-Id: <980815102425.ZM18907@candle.brasslantern.com> Date: Sat, 15 Aug 1998 10:24:25 -0700 In-Reply-To: <980809205100.ZM24722@candle.brasslantern.com> Comments: In reply to "Bart Schaefer" "Re: init files" (Aug 9, 8:51pm) References: <19980809150805.47993@astaroth.nit.gwu.edu> <980809150442.ZM21544@candle.brasslantern.com> <19980809210204.33286@astaroth.nit.gwu.edu> <980809205100.ZM24722@candle.brasslantern.com> X-Mailer: Z-Mail (4.0b.820 20aug96) To: Sweth Chandramouli , ZSH Users Subject: Re: init files MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"yJ-Lc.0.Rk.PFSrr"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1719 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu On Aug 9, 8:51pm, I wrote: } Subject: Re: init files } } [1] DEFAULT--rc-enabled shell => RCS } unless } `-f' flag present on shell invocation => NO_RCS } unless } `+f' flag present on shell invocation => RCS } unless } ( `unsetopt RCS' called in /etc/zshenv => NO_RCS } or } `setopt RCS' called in /etc/zshenv => RCS ) } } Note that there are two "oddities" here: First, +f always wins over -f This turns out not to be true; I was misled by some setopts in /etc/zshenv, which I've since deleted. It should read: [1] DEFAULT--rc-enabled shell => RCS unless ( `-f' flag present on shell invocation => NO_RCS or `+f' flag present on shell invocation => RCS ) unless ( `unsetopt RCS' called in /etc/zshenv => NO_RCS or `setopt RCS' called in /etc/zshenv => RCS ) -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com