about summary refs log tree commit diff
path: root/Src/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/init.c')
-rw-r--r--Src/init.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/Src/init.c b/Src/init.c
index f3576aadd..9fc4a81fb 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -757,25 +757,43 @@ run_init_scripts(void)
 	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");