mirror of
https://github.com/weechat/weechat.git
synced 2026-07-04 00:33:13 +02:00
api: add support of environment variables in function string_eval_expression() and command /eval (issue #388)
This commit is contained in:
@@ -7195,9 +7195,10 @@ command_init ()
|
||||
" 3. a color (format: \"color:xxx\")\n"
|
||||
" 4. an info (format: \"info:name,arguments\", arguments are "
|
||||
"optional)\n"
|
||||
" 5. an option (format: \"file.section.option\")\n"
|
||||
" 6. a local variable in buffer\n"
|
||||
" 7. a hdata name/variable (the value is automatically converted "
|
||||
" 5. an environment variable (format: \"env:XXX\")\n"
|
||||
" 6. an option (format: \"file.section.option\")\n"
|
||||
" 7. a local variable in buffer\n"
|
||||
" 8. a hdata name/variable (the value is automatically converted "
|
||||
"to string), by default \"window\" and \"buffer\" point to current "
|
||||
"window/buffer.\n"
|
||||
"Format for hdata can be one of following:\n"
|
||||
@@ -7214,6 +7215,7 @@ command_init ()
|
||||
"\n"
|
||||
"Examples (simple strings):\n"
|
||||
" /eval -n ${info:version} ==> 0.4.3\n"
|
||||
" /eval -n ${env:HOME} ==> /home/user\n"
|
||||
" /eval -n ${weechat.look.scroll_amount} ==> 3\n"
|
||||
" /eval -n ${window} ==> 0x2549aa0\n"
|
||||
" /eval -n ${window.buffer} ==> 0x2549320\n"
|
||||
|
||||
+11
-3
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user