diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2015-04-26 11:50:39 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2015-04-26 11:50:39 +0200 |
commit | 6b2c9d2cb8ae0057faffd29fc61b0ab67ae71c7f (patch) | |
tree | 44514243a47699ae64bb14dc21e243b549698ecb /src/core/wee-eval.c | |
parent | 80f446a4b40cf93c431bcd6110d5386a46ddb5b2 (diff) | |
download | weechat-6b2c9d2cb8ae0057faffd29fc61b0ab67ae71c7f.zip |
api: add support of environment variables in function string_eval_expression() and command /eval (issue #388)
Diffstat (limited to 'src/core/wee-eval.c')
-rw-r--r-- | src/core/wee-eval.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/core/wee-eval.c b/src/core/wee-eval.c index acf03aa89..8d0216718 100644 --- a/src/core/wee-eval.c +++ b/src/core/wee-eval.c @@ -352,7 +352,15 @@ eval_replace_vars_cb (void *data, const char *text) return strdup ((ptr_value) ? ptr_value : ""); } - /* 7. option: if found, return this value */ + /* 7. environment variable */ + if (strncmp (text, "env:", 4) == 0) + { + ptr_value = getenv (text + 4); + if (ptr_value) + return strdup (ptr_value); + } + + /* 8. option: if found, return this value */ if (strncmp (text, "sec.data.", 9) == 0) { ptr_value = hashtable_get (secure_hashtable_data, text + 9); @@ -385,7 +393,7 @@ eval_replace_vars_cb (void *data, const char *text) } } - /* 8. local variable in buffer */ + /* 9. local variable in buffer */ ptr_buffer = hashtable_get (pointers, "buffer"); if (ptr_buffer) { @@ -394,7 +402,7 @@ eval_replace_vars_cb (void *data, const char *text) return strdup (ptr_value); } - /* 9. hdata */ + /* 10. hdata */ value = NULL; hdata_name = NULL; list_name = NULL; |