diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2015-03-07 21:18:34 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2015-03-07 21:18:34 +0100 |
commit | ebf04404a21733b749edd84b32af1f5f63dfdfe3 (patch) | |
tree | 08970160122519fef12a86bccb0ca602555e8359 /src | |
parent | 4a4687c4ce4e5aa09e54531c662355d294dcaa6c (diff) | |
download | sciteco-ebf04404a21733b749edd84b32af1f5f63dfdfe3.tar.gz |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
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++) { |