mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
add some code to deal with a common $HOME convention
This commit is contained in:
parent
c4a1e7da9b
commit
bd33a24beb
@ -828,8 +828,19 @@ cmd_export(ProfWin *window, const char *const command, gchar **args)
|
|||||||
cons_show("");
|
cons_show("");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else if(args[0]) {
|
} else if(args[0]) {
|
||||||
int fd = open(args[0], O_WRONLY | O_CREAT, 00600);
|
GString *fname = g_string_new("");
|
||||||
GSList *list = NULL;
|
GSList *list = NULL;
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
/* deal with the ~ convention for $HOME */
|
||||||
|
if(args[0][0] == '~') {
|
||||||
|
fname = g_string_append(fname, getenv("HOME"));
|
||||||
|
fname = g_string_append(fname, args[0] + 1);
|
||||||
|
} else {
|
||||||
|
fname = g_string_append(fname, args[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
fd = open(fname->str, O_WRONLY | O_CREAT, 00600);
|
||||||
|
|
||||||
if(-1 == fd) {
|
if(-1 == fd) {
|
||||||
cons_show("error: cannot open %s: %s", args[0], strerror(errno));
|
cons_show("error: cannot open %s: %s", args[0], strerror(errno));
|
||||||
@ -866,6 +877,7 @@ cmd_export(ProfWin *window, const char *const command, gchar **args)
|
|||||||
|
|
||||||
g_slist_free(list);
|
g_slist_free(list);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
g_string_free(fname, TRUE);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
write_error:
|
write_error:
|
||||||
cons_show("error: write failed: %s", strerror(errno));
|
cons_show("error: write failed: %s", strerror(errno));
|
||||||
|
Loading…
Reference in New Issue
Block a user