From ebf04404a21733b749edd84b32af1f5f63dfdfe3 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sat, 7 Mar 2015 21:18:34 +0100 Subject: canonicalize $SCITECOCONFIG and $SCITECOPATH variables * this makes them absolute and also resolves links on Unix * macros can now assume the corresponding Q-regs to be absolute * Currently this does not make a big difference since the working directory of the SciTECO process cannot be changed. Once I implement a command to change the working dir, this is essential. --- doc/sciteco.1.in | 7 +++++++ src/main.cpp | 17 ++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/doc/sciteco.1.in b/doc/sciteco.1.in index 077d807..16df9c4 100644 --- a/doc/sciteco.1.in +++ b/doc/sciteco.1.in @@ -168,6 +168,13 @@ On all other platforms (including UNIX/Linux) this variable defaults to the standard library installation path at .BR "@scitecolibdir@" . . +.LP +Both the \fBSCITECOCONFIG\fP and \fBSCITECOPATH\fP environment +variables are canonicalized to absolute paths. +Therefore it is possible to define them relative to the +working directory of \*(ST when it starts up while macros +can work with the corresponding registers to locate files +even when the working directory of \*(ST is changed later on. . .SH FILES . diff --git a/src/main.cpp b/src/main.cpp index a2de09e..f17f942 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -166,9 +166,12 @@ process_options(int &argc, char **&argv) static inline void initialize_environment(const gchar *program) { - gchar *default_configpath; + gchar *default_configpath, *abs_path; gchar **env; + /* + * Initialize $SCITECOCONFIG and $SCITECOPATH + */ default_configpath = get_default_config_path(program); g_setenv("SCITECOCONFIG", default_configpath, FALSE); #ifdef G_OS_WIN32 @@ -181,6 +184,18 @@ initialize_environment(const gchar *program) #endif g_free(default_configpath); + /* + * $SCITECOCONFIG and $SCITECOPATH may still be relative. + * They are canonicalized, so macros can use them even + * if the current working directory changes. + */ + abs_path = get_absolute_path(g_getenv("SCITECOCONFIG")); + g_setenv("SCITECOCONFIG", abs_path, TRUE); + g_free(abs_path); + abs_path = get_absolute_path(g_getenv("SCITECOPATH")); + g_setenv("SCITECOPATH", abs_path, TRUE); + g_free(abs_path); + env = g_listenv(); for (gchar **key = env; *key; key++) { -- cgit v1.2.3