aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/interface-curses.cpp
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2015-06-14 19:08:06 +0200
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2015-06-14 19:08:06 +0200
commit15409bae5ffdfce4ef17c4ccf14c8cd4c1b8f37e (patch)
tree852b915a69d57679a05ef5fec0ee6608cdcf2dee /src/interface-curses.cpp
parent573951d4e2bb4fb1d14212583a59ce76344593cc (diff)
downloadsciteco-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/interface-curses.cpp')
-rw-r--r--src/interface-curses.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/interface-curses.cpp b/src/interface-curses.cpp
index 5f8a00c..1dcca8f 100644
--- a/src/interface-curses.cpp
+++ b/src/interface-curses.cpp
@@ -178,6 +178,13 @@ InterfaceCurses::init_interactive(void)
void
InterfaceCurses::init_batch(void)
{
+ /*
+ * NOTE: It's still safe to use g_getenv().
+ * Actually the process environment has not yet been
+ * imported into the Q-Register table.
+ * Also, the batch mode initialization will be
+ * simplified soon, anyway.
+ */
const gchar *term = g_getenv("TERM");
/*
@@ -227,7 +234,13 @@ InterfaceCurses::init_interactive(void)
{
const gchar *term = g_getenv("TERM");
- /* at least try to report a broken $TERM */
+ /*
+ * At least try to report a broken $TERM.
+ * g_getenv() may still be used here since we must refer to
+ * same value as used in init_batch() as opposed to the
+ * current value of the "$TERM" register.
+ * Also, this code will have to be simplified soon, anyway.
+ */
if (!term || !*term) {
g_fprintf(stderr, "Error initializing interactive mode: "
"$TERM is unset or empty.\n");
@@ -816,6 +829,10 @@ InterfaceCurses::event_loop_impl(void)
* Set window title to a reasonable default,
* in case it is not reset immediately by the
* shell.
+ * FIXME: It may be unsafe to access $TERM here
+ * and the value of Q-Register $TERM may have
+ * diverged. This should be adapted once we rewrite
+ * batch-mode initialization!
*/
#if !PDCURSES && defined(HAVE_TIGETSTR)
set_window_title(g_getenv("TERM") ? : "");