summaryrefslogtreecommitdiff
path: root/src/plugins/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/scripts')
-rw-r--r--src/plugins/scripts/weechat-script.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/plugins/scripts/weechat-script.c b/src/plugins/scripts/weechat-script.c
index c5ee3cca3..f95809426 100644
--- a/src/plugins/scripts/weechat-script.c
+++ b/src/plugins/scripts/weechat-script.c
@@ -96,9 +96,47 @@ weechat_script_search_full_name (t_weechat_plugin *plugin,
int length;
struct stat st;
- if ((strstr(filename, "/")) || (strstr(filename, "\\")))
+ if (filename[0] == '~')
+ {
+ dir_home = getenv ("HOME");
+ if (!dir_home)
+ return NULL;
+ length = strlen (dir_home) + strlen (filename + 1) + 1;
+ final_name = (char *) malloc (length);
+ if (final_name)
+ {
+ snprintf (final_name, length, "%s%s", dir_home, filename + 1);
+ return final_name;
+ }
+ return NULL;
+ }
+
+#ifdef _WIN32
+ if (strstr(filename, "\\"))
+#else
+ if (strstr(filename, "/"))
+#endif
return strdup(filename);
+ /* try WeeChat user's autoload dir */
+ dir_home = plugin->get_info (plugin, "weechat_dir", NULL);
+ if (dir_home)
+ {
+ length = strlen (dir_home) + strlen (language) + 8 + strlen (filename) + 16;
+ final_name = (char *) malloc (length);
+ if (final_name)
+ {
+ snprintf (final_name, length, "%s/%s/autoload/%s", dir_home, language, filename);
+ if ((stat (final_name, &st) == 0) && (st.st_size > 0))
+ {
+ free (dir_home);
+ return final_name;
+ }
+ free (final_name);
+ }
+ free (dir_home);
+ }
+
/* try WeeChat user's dir */
dir_home = plugin->get_info (plugin, "weechat_dir", NULL);
if (dir_home)