summaryrefslogtreecommitdiff
path: root/src/plugins/script/script-config.c
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2015-06-19 21:12:47 +0200
committerSébastien Helleu <flashcode@flashtux.org>2015-06-19 21:12:47 +0200
commit292830b5bf103bbef7b3b3ee079433c6e2385a46 (patch)
tree28b5d68995cda35fd221c1d75d30b104edadaf22 /src/plugins/script/script-config.c
parentacb03201b41591158996a23bd6f3699894bf6ae3 (diff)
downloadweechat-292830b5bf103bbef7b3b3ee079433c6e2385a46.zip
script: evaluate content of option script.scripts.dir (issue #388)
Diffstat (limited to 'src/plugins/script/script-config.c')
-rw-r--r--src/plugins/script/script-config.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/plugins/script/script-config.c b/src/plugins/script/script-config.c
index 52e1341c1..59983a8ce 100644
--- a/src/plugins/script/script-config.c
+++ b/src/plugins/script/script-config.c
@@ -152,26 +152,30 @@ char *
script_config_get_dir ()
{
const char *weechat_home;
- char *path, *path2;
+ char *path, *path2, *path3;
- weechat_home = weechat_info_get ("weechat_dir", NULL);
+ path = NULL;
+ path2 = NULL;
+ path3 = NULL;
- path = weechat_string_expand_home (weechat_config_string (script_config_scripts_dir));
- path2 = weechat_string_replace ((path) ?
- path : weechat_config_string (script_config_scripts_dir),
- "%h", weechat_home);
-
- if (path && path2)
+ path = weechat_string_eval_expression (
+ weechat_config_string (script_config_scripts_dir), NULL, NULL, NULL);
+ if (path)
{
- free (path);
- path = NULL;
+ path2 = weechat_string_expand_home (path);
+ if (path2)
+ {
+ weechat_home = weechat_info_get ("weechat_dir", NULL);
+ path3 = weechat_string_replace (path2, "%h", weechat_home);
+ }
}
- if (path2)
- return path2;
if (path)
- return path;
- return strdup (weechat_config_string (script_config_scripts_dir));
+ free (path);
+ if (path2)
+ free (path2);
+
+ return path3;
}
/*
@@ -689,7 +693,9 @@ script_config_init ()
script_config_scripts_dir = weechat_config_new_option (
script_config_file, ptr_section,
"dir", "string",
- N_("local cache directory for scripts"),
+ N_("local cache directory for scripts; \"%h\" at beginning of string "
+ "is replaced by WeeChat home (\"~/.weechat\" by default) "
+ "(note: content is evaluated, see /help eval)"),
NULL, 0, 0, "%h/script", NULL, 0, NULL, NULL,
NULL, NULL, NULL, NULL);
script_config_scripts_hold = weechat_config_new_option (