changeset 20514:ac0f7acdc3fd

avoid executing startup file twice when using run-octave script (bug #45872) * site-rcfile: Rename from local-rcfile. * version-rcfile: Rename from main-rcfile. * scripts/startup/module.mk: Update to match new names. (install-startup-files, uninstall-startup-files): Move rules here from scripts/module.mk. * site-rcfile, version-rcfile: Note environment variables that may be used to select site and version rcfiles to execute. * run-octave.in (OCTAVE_VERSION_INITFILE): Define to use version-rcfile from source tree. (OCTAVE_SITE_INITFILE): Update to use site-rcfile from source tree.
author John W. Eaton <jwe@octave.org>
date Fri, 04 Sep 2015 12:45:46 -0400
parents a9a1f021d96b
children ad7fe3cb6fd2
files run-octave.in scripts/module.mk scripts/startup/local-rcfile scripts/startup/main-rcfile scripts/startup/module.mk scripts/startup/site-rcfile scripts/startup/version-rcfile
diffstat 7 files changed, 65 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- a/run-octave.in	Thu Sep 03 19:00:53 2015 -0400
+++ b/run-octave.in	Fri Sep 04 12:45:46 2015 -0400
@@ -94,7 +94,8 @@
 OCTAVE_DEFAULT_QT_SETTINGS="$builddir/libgui/default-qt-settings"; export OCTAVE_DEFAULT_QT_SETTINGS
 OCTAVE_JAVA_DIR="$builddir/scripts/java"; export OCTAVE_JAVA_DIR
 OCTAVE_LOCALE_DIR="$builddir/libgui/languages"; export OCTAVE_LOCALE_DIR
-OCTAVE_SITE_INITFILE="$top_srcdir/scripts/startup/main-rcfile"; export OCTAVE_SITE_INITFILE
+OCTAVE_SITE_INITFILE="$top_srcdir/scripts/startup/site-rcfile"; export OCTAVE_SITE_INITFILE
+OCTAVE_VERSION_INITFILE="$top_srcdir/scripts/startup/version-rcfile"; export OCTAVE_VERSION_INITFILE
 
 exec $builddir/libtool --mode=execute $driver \
   "$octave_executable" --no-init-path --path="$LOADPATH" \
--- a/scripts/module.mk	Thu Sep 03 19:00:53 2015 -0400
+++ b/scripts/module.mk	Fri Sep 04 12:45:46 2015 -0400
@@ -160,33 +160,6 @@
 
 uninstall-local: uninstall-startup-files uninstall-pkg-add
 
-install-startup-files:
-	$(MKDIR_P) $(DESTDIR)$(fcnfiledir)/startup
-	if test -f $(DESTDIR)$(fcnfiledir)/startup/octaverc; then true; \
-	else \
-	  $(INSTALL_DATA) $(srcdir)/$(SYSTEM_STARTUP_FILE_SRC) \
-	    $(DESTDIR)$(fcnfiledir)/startup/octaverc; \
-	fi
-	if test -f $(DESTDIR)$(fcnfiledir)/startup/inputrc; then true; \
-	else \
-	  $(INSTALL_DATA) $(srcdir)/$(SYSTEM_INPUTRC_FILE_SRC) \
-	    $(DESTDIR)$(fcnfiledir)/startup/inputrc; \
-	fi
-	$(MKDIR_P) $(DESTDIR)$(localfcnfiledir)/startup
-	if test -f $(DESTDIR)$(localfcnfiledir)/startup/octaverc; \
-	then true; \
-	else \
-	  $(INSTALL_DATA) $(srcdir)/$(LOCAL_STARTUP_FILE_SRC) \
-	    $(DESTDIR)$(localfcnfiledir)/startup/octaverc; \
-	fi
-.PHONY: install-startup-files
-
-uninstall-startup-files:
-	rm -f $(DESTDIR)$(fcnfiledir)/startup/octaverc
-	rm -f $(DESTDIR)$(fcnfiledir)/startup/inputrc
-	rm -f $(DESTDIR)$(localfcnfiledir)/startup/octaverc
-.PHONY: uninstall-startup-files
-
 install-pkg-add:
 	for f in $(PKG_ADD_FILES); do \
 	  if [ -n "`cat $$f`" ]; then \
--- a/scripts/startup/local-rcfile	Thu Sep 03 19:00:53 2015 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-## System-wide startup file for Octave.
-##
-## This file should contain any commands that should be executed each
-## time Octave starts for every user at this site.
--- a/scripts/startup/main-rcfile	Thu Sep 03 19:00:53 2015 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-## System-wide startup file for Octave.
-##
-## This file should contain any commands that should be executed each
-## time Octave starts for every user at this site.
-
-## Configure readline using the file inputrc in the Octave startup
-## directory.
-
-readline_read_init_file (sprintf ("%s%s%s",
-                                  octave_config_info ("startupfiledir"),
-                                  filesep, "inputrc"));
-
-if (strcmp (PAGER (), "less") && isempty (getenv ("LESS")))
-  PAGER_FLAGS ('-e -X -P"-- less ?pB(%pB\\%):--. (f)orward, (b)ack, (q)uit$"');
-endif
-
-## This appears here instead of in the pkg/PKG_ADD file so that --norc
-## will also skip automatic loading of packages.
-
-pkg ("load", "auto");
-
-atexit ("__finish__");
--- a/scripts/startup/module.mk	Thu Sep 03 19:00:53 2015 -0400
+++ b/scripts/startup/module.mk	Fri Sep 04 12:45:46 2015 -0400
@@ -3,15 +3,15 @@
 scripts_startup_FCN_FILES = \
   scripts/startup/__finish__.m
 
-LOCAL_STARTUP_FILE_SRC  = scripts/startup/local-rcfile
+SITE_STARTUP_FILE_SRC  = scripts/startup/site-rcfile
 
-SYSTEM_STARTUP_FILE_SRC = scripts/startup/main-rcfile
+VERSION_STARTUP_FILE_SRC = scripts/startup/version-rcfile
 
 SYSTEM_INPUTRC_FILE_SRC = scripts/startup/inputrc
 
 STARTUP_FILE_SRC = \
-  $(LOCAL_STARTUP_FILE_SRC) \
-  $(SYSTEM_STARTUP_FILE_SRC) \
+  $(SITE_STARTUP_FILE_SRC) \
+  $(VERSION_STARTUP_FILE_SRC) \
   $(SYSTEM_INPUTRC_FILE_SRC)
 
 scripts_startupdir = $(fcnfiledir)/startup
@@ -25,3 +25,30 @@
 DIRSTAMP_FILES += scripts/startup/$(octave_dirstamp)
 
 scripts_EXTRA_DIST += $(STARTUP_FILE_SRC)
+
+install-startup-files:
+	$(MKDIR_P) $(DESTDIR)$(fcnfiledir)/startup
+	if test -f $(DESTDIR)$(fcnfiledir)/startup/octaverc; then true; \
+	else \
+	  $(INSTALL_DATA) $(srcdir)/$(VERSION_STARTUP_FILE_SRC) \
+	    $(DESTDIR)$(fcnfiledir)/startup/octaverc; \
+	fi
+	if test -f $(DESTDIR)$(fcnfiledir)/startup/inputrc; then true; \
+	else \
+	  $(INSTALL_DATA) $(srcdir)/$(SYSTEM_INPUTRC_FILE_SRC) \
+	    $(DESTDIR)$(fcnfiledir)/startup/inputrc; \
+	fi
+	$(MKDIR_P) $(DESTDIR)$(localfcnfiledir)/startup
+	if test -f $(DESTDIR)$(localfcnfiledir)/startup/octaverc; \
+	then true; \
+	else \
+	  $(INSTALL_DATA) $(srcdir)/$(SITE_STARTUP_FILE_SRC) \
+	    $(DESTDIR)$(localfcnfiledir)/startup/octaverc; \
+	fi
+.PHONY: install-startup-files
+
+uninstall-startup-files:
+	rm -f $(DESTDIR)$(fcnfiledir)/startup/octaverc
+	rm -f $(DESTDIR)$(fcnfiledir)/startup/inputrc
+	rm -f $(DESTDIR)$(localfcnfiledir)/startup/octaverc
+.PHONY: uninstall-startup-files
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/startup/site-rcfile	Fri Sep 04 12:45:46 2015 -0400
@@ -0,0 +1,7 @@
+## System-wide startup file for Octave.
+##
+## If the environment variable OCTAVE_SITE_INITFILE is set when Octave
+## starts, then that file is executed instead of this file.
+##
+## This file should contain any commands that should be executed each
+## time Octave starts for every user at this site.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/startup/version-rcfile	Fri Sep 04 12:45:46 2015 -0400
@@ -0,0 +1,25 @@
+## System-wide startup file for Octave.
+##
+## If the environment variable OCTAVE_VERSION_INITFILE is set when Octave
+## starts, then that file is executed instead of this file.
+##
+## This file should contain any commands that should be executed each
+## time Octave starts for every user at this site.
+
+## Configure readline using the file inputrc in the Octave startup
+## directory.
+
+readline_read_init_file (sprintf ("%s%s%s",
+                                  octave_config_info ("startupfiledir"),
+                                  filesep, "inputrc"));
+
+if (strcmp (PAGER (), "less") && isempty (getenv ("LESS")))
+  PAGER_FLAGS ('-e -X -P"-- less ?pB(%pB\\%):--. (f)orward, (b)ack, (q)uit$"');
+endif
+
+## This appears here instead of in the pkg/PKG_ADD file so that --norc
+## will also skip automatic loading of packages.
+
+pkg ("load", "auto");
+
+atexit ("__finish__");