diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2015-06-14 19:08:06 +0200 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2015-06-14 19:08:06 +0200 |
commit | 15409bae5ffdfce4ef17c4ccf14c8cd4c1b8f37e (patch) | |
tree | 852b915a69d57679a05ef5fec0ee6608cdcf2dee /src/ioview.cpp | |
parent | 573951d4e2bb4fb1d14212583a59ce76344593cc (diff) | |
download | sciteco-15409bae5ffdfce4ef17c4ccf14c8cd4c1b8f37e.tar.gz |
handle environment variables more consistently
* the registers beginning with "$" are exported into sub-process
environments. Therefore macros can now modify the environment
(variables) of commands executed via EC/EG.
A variable can be modified temporarily, e.g.:
[[$FOO] ^U[$FOO]bar$ EC...$ ][$FOO]
* SciTECO accesses the global environment registers instead of
using g_getenv(). Therefore now, tilde-expansion will always
use the current value of the "$HOME" register.
Previously, both register and environment variable could diverge.
* This effectively fully maps the process environment to a subset of
Q-Registers beginning with "$".
* This hasn't been implemented by mapping those registers to
special implementations that updates the process environment
directly, since g_setenv() is non-thread-safe on UNIX
and we're expected to have threads soon - at least in the GTK+ UI.
Diffstat (limited to 'src/ioview.cpp')
-rw-r--r-- | src/ioview.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/ioview.cpp b/src/ioview.cpp index e43fc2c..713b3fb 100644 --- a/src/ioview.cpp +++ b/src/ioview.cpp @@ -36,6 +36,7 @@ #include "interface.h" #include "undo.h" #include "error.h" +#include "qregisters.h" #include "ioview.h" #ifdef HAVE_WINDOWS_H @@ -675,12 +676,14 @@ IOView::save(const gchar *filename) * * This supports only strings with a "~" prefix. * A user name after "~" is not supported. - * The $HOME environment variable is used to retrieve + * The $HOME environment variable/register is used to retrieve * the current user's home directory. */ gchar * expand_path(const gchar *path) { + gchar *home, *ret; + if (!path) path = ""; @@ -693,7 +696,11 @@ expand_path(const gchar *path) * but this ensures that a proper path is constructed even if * it does (e.g. $HOME is changed later on). */ - return g_build_filename(g_getenv("HOME"), path+1, NIL); + home = QRegisters::globals["$HOME"]->get_string(); + ret = g_build_filename(home, path+1, NIL); + g_free(home); + + return ret; } #ifdef G_OS_UNIX |