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

Re: zsh startup files



Peter Stephenson wrote:
> One possibility is that we could allow an option to be set either on the
> command line or in /etc/zshenv, so that all system files are run first.
> 
> How about the option name GLOBAL_RCS_FIRST and the letter -b (for begin, we
> don't have many spare letters)?  It should be an easy patch for zsh 3.1.

Unfortunately -b has the undocumented effect of ending option processing,
so it will have to be -d.

--- Doc/Zsh/files.yo.minusd	Thu Feb  4 16:11:49 1999
+++ Doc/Zsh/files.yo	Thu Mar 25 10:24:47 1999
@@ -20,6 +20,13 @@
 Finally, if the shell is a login shell, tt(/etc/zlogin) and
 tt($ZDOTDIR/.zlogin) are read.
 
+If the option tt(GLOBAL_RCS_FIRST) is set when the shell is invoked or in
+the file tt(/etc/zshenv), then all the applicable global startup files are
+read before all the users', so that the order becomes tt(/etc/zshenv)
+... tt(/etc/zlogin), tt($ZDOTDIR/.zshenv) ... tt($ZDOTDIR/.zlogin).
+After tt(/etc/zshenv) has been read, changing the option has no further
+effect.
+
 When a login shell exits, the files tt($ZDOTDIR/.zlogout) and then
 tt(/etc/zlogout) are read.  This happens with either an explicit exit
 via the tt(exit) or tt(logout) commands, or an implict exit by reading
--- Doc/Zsh/options.yo.minusd	Mon Mar 22 18:53:18 1999
+++ Doc/Zsh/options.yo	Thu Mar 25 10:47:33 1999
@@ -326,6 +326,16 @@
 Perform filename generation (globbing).
 (See noderef(Filename Generation).)
 )
+pindex(GLOBAL_RCS_FIRST)
+cindex(startup files, changing order)
+cindex(files, startup, changing order)
+item(tt(GLOBAL_RCS_FIRST) (tt(-d)))(
+If this option is set, and the tt(RCS) option is also set (as it is by
+default), then the order in which startup files are sourced after
+tt(/etc/zshenv) changes to tt(/etc/zprofile), tt(/etc/zshrc),
+tt(/etc/zlogin), tt(.zshenv), tt(.zprofile), tt(.zshrc), tt(.zlogin).
+The order of tt(.zlogout) and tt(/etc/zlogout) is not affected.
+)
 pindex(GLOB_ASSIGN)
 item(tt(GLOB_ASSIGN))(
 If this option is set, filename generation (globbing) is
@@ -1049,6 +1059,7 @@
 subsect(Also note)
 startsitem()
 sitem(tt(-A))(Used by tt(set) for setting arrays)
+sitem(tt(-b))(Used on the command line to specify end of option processing)
 sitem(tt(-c))(Used on the command line to specify a single command)
 sitem(tt(-m))(Used by tt(setopt) for pattern-matching option setting)
 sitem(tt(-o))(Used in all places to allow use of long option names)
--- Src/init.c.minusd	Wed Mar 17 13:49:10 1999
+++ Src/init.c	Thu Mar 25 10:09:04 1999
@@ -757,25 +757,43 @@
 	source(GLOBAL_ZSHENV);
 #endif
 	if (isset(RCS)) {
+	    int globalfirst = isset(GLOBALRCSFIRST);
+	    if (globalfirst) {
+#ifdef GLOBAL_ZPROFILE
+		if (islogin)
+		    source(GLOBAL_ZPROFILE);
+#endif
+#ifdef GLOBAL_ZSHRC
+		if (interact)
+		    source(GLOBAL_ZSHRC);
+#endif
+#ifdef GLOBAL_ZLOGIN
+		if (islogin)
+		    source(GLOBAL_ZLOGIN);
+#endif
+	    }
 	    if (unset(PRIVILEGED))
 		sourcehome(".zshenv");
 	    if (islogin) {
 #ifdef GLOBAL_ZPROFILE
-		source(GLOBAL_ZPROFILE);
+		if (!globalfirst)
+		    source(GLOBAL_ZPROFILE);
 #endif
 		if (unset(PRIVILEGED))
 		    sourcehome(".zprofile");
 	    }
 	    if (interact) {
 #ifdef GLOBAL_ZSHRC
-		source(GLOBAL_ZSHRC);
+		if (!globalfirst)
+		    source(GLOBAL_ZSHRC);
 #endif
 		if (unset(PRIVILEGED))
 		    sourcehome(".zshrc");
 	    }
 	    if (islogin) {
 #ifdef GLOBAL_ZLOGIN
-		source(GLOBAL_ZLOGIN);
+		if (!globalfirst)
+		    source(GLOBAL_ZLOGIN);
 #endif
 		if (unset(PRIVILEGED))
 		    sourcehome(".zlogin");
--- Src/options.c.minusd	Thu Mar 11 11:31:20 1999
+++ Src/options.c	Thu Mar 25 10:38:43 1999
@@ -114,6 +114,7 @@
 {NULL, "flowcontrol",	      OPT_ALL,			 FLOWCONTROL},
 {NULL, "functionargzero",     OPT_EMULATE|OPT_NONBOURNE, FUNCTIONARGZERO},
 {NULL, "glob",		      OPT_ALL,			 GLOBOPT},
+{NULL, "globalrcsfirst",      0,			 GLOBALRCSFIRST},
 {NULL, "globassign",	      OPT_EMULATE|OPT_CSH,	 GLOBASSIGN},
 {NULL, "globcomplete",	      0,			 GLOBCOMPLETE},
 {NULL, "globdots",	      0,			 GLOBDOTS},
@@ -228,7 +229,7 @@
     /* > */  0,
     /* ? */  0,
     /* @ */  0,
-    /* A */  0,
+    /* A */  0,			/* use with set for arrays */
     /* B */ -BEEP,
     /* C */ -CLOBBER,
     /* D */  PUSHDTOHOME,
@@ -261,9 +262,9 @@
     /* _ */  0,
     /* ` */  0,
     /* a */  ALLEXPORT,
-    /* b */  0,
-    /* c */  0,
-    /* d */  0,
+    /* b */  0,			/* in non-Bourne shells, end of options */
+    /* c */  0,			/* command follows */
+    /* d */  GLOBALRCSFIRST,
     /* e */  ERREXIT,
     /* f */ -RCS,
     /* g */  HISTIGNORESPACE,
@@ -274,7 +275,7 @@
     /* l */  LOGINSHELL,
     /* m */  MONITOR,
     /* n */ -EXECOPT,
-    /* o */  0,
+    /* o */  0,			/* long option name follows */
     /* p */  PRIVILEGED,
     /* q */  0,
     /* r */  RESTRICTED,
--- Src/zsh.h.minusd	Thu Mar 25 10:03:48 1999
+++ Src/zsh.h	Thu Mar 25 10:03:51 1999
@@ -1085,6 +1085,7 @@
     EXTENDEDHISTORY,
     FLOWCONTROL,
     FUNCTIONARGZERO,
+    GLOBALRCSFIRST,
     GLOBOPT,
     GLOBASSIGN,
     GLOBCOMPLETE,

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy



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