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. --- src/main.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src') 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