aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2015-03-07 21:18:34 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2015-03-07 21:18:34 +0100
commitebf04404a21733b749edd84b32af1f5f63dfdfe3 (patch)
tree08970160122519fef12a86bccb0ca602555e8359
parent4a4687c4ce4e5aa09e54531c662355d294dcaa6c (diff)
downloadsciteco-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.
-rw-r--r--doc/sciteco.1.in7
-rw-r--r--src/main.cpp17
2 files changed, 23 insertions, 1 deletions
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++) {