summaryrefslogtreecommitdiff
path: root/src/plugins/fset/fset-option.c
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2024-02-21 22:05:16 +0100
committerSébastien Helleu <flashcode@flashtux.org>2024-02-21 22:05:16 +0100
commitef5ebc19e946efcbdf9cdf714a7d9250e6f975be (patch)
tree037eee0c2017bc73e2110afb495e908ad09eba9e /src/plugins/fset/fset-option.c
parent76998665f4040f032adfa210e45f524de871e8d5 (diff)
downloadweechat-ef5ebc19e946efcbdf9cdf714a7d9250e6f975be.zip
fset: allow filename starting with "~" in command `/fset -export`
Diffstat (limited to 'src/plugins/fset/fset-option.c')
-rw-r--r--src/plugins/fset/fset-option.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/plugins/fset/fset-option.c b/src/plugins/fset/fset-option.c
index 5b1f69bc3..b8f276555 100644
--- a/src/plugins/fset/fset-option.c
+++ b/src/plugins/fset/fset-option.c
@@ -1392,16 +1392,23 @@ int
fset_option_export (const char *filename, int with_help)
{
int num_options, i;
- char *line;
+ char *filename2, *line;
FILE *file;
struct t_fset_option *ptr_fset_option;
struct t_hashtable *hashtable_pointers, *hashtable_extra_vars;
- file = fopen (filename, "w");
+ filename2 = weechat_string_expand_home (filename);
+ if (!filename2)
+ return 0;
+
+ file = fopen (filename2, "w");
if (!file)
+ {
+ free (filename2);
return 0;
+ }
- chmod (filename, 0600);
+ chmod (filename2, 0600);
hashtable_pointers = weechat_hashtable_new (
8,
@@ -1458,6 +1465,7 @@ fset_option_export (const char *filename, int with_help)
weechat_hashtable_free (hashtable_pointers);
if (hashtable_extra_vars)
weechat_hashtable_free (hashtable_extra_vars);
+ free (filename2);
return 1;
}