diff --git a/src/mime/backend/mailcap.c b/src/mime/backend/mailcap.c index 2f8d21b2f..207b44bc8 100644 --- a/src/mime/backend/mailcap.c +++ b/src/mime/backend/mailcap.c @@ -535,7 +535,7 @@ format_command(unsigned char *command, unsigned char *type, int copiousoutput) } } } - +#if 0 if (copiousoutput) { unsigned char *pager = getenv("PAGER"); @@ -552,7 +552,7 @@ format_command(unsigned char *command, unsigned char *type, int copiousoutput) add_to_string(&cmd, pager); } } - +#endif return cmd.source; } diff --git a/src/session/download.c b/src/session/download.c index b0d573809..cd1e24012 100644 --- a/src/session/download.c +++ b/src/session/download.c @@ -301,6 +301,23 @@ abort_download_and_beep(struct file_download *file_download, struct terminal *te abort_download(file_download); } +static void +read_from_popen(struct session *ses, unsigned char *handler) +{ + FILE *pop = popen(handler, "r"); + + if (pop) { + int fd = fileno(pop); + + if (fd > 0) { + unsigned char buf[48]; + + snprintf(buf, 48, "file:///dev/fd/%d", fd); + goto_url(ses, buf); + } + } +} + static void download_data_store(struct download *download, struct file_download *file_download) { @@ -338,11 +355,16 @@ download_data_store(struct download *download, struct file_download *file_downlo prealloc_truncate(file_download->handle, file_download->seek); close(file_download->handle); file_download->handle = -1; - exec_on_terminal(term, file_download->external_handler, + if (file_download->copiousoutput) { + read_from_popen(file_download->ses, + file_download->external_handler); + } else { + exec_on_terminal(term, file_download->external_handler, file_download->file, !!file_download->block); - file_download->delete = 0; - abort_download_and_beep(file_download, term); + file_download->delete = 0; + abort_download_and_beep(file_download, term); + } return; } @@ -974,23 +996,6 @@ tp_display(struct type_query *type_query) done_type_query(type_query); } -static void -read_from_popen(struct type_query *type_query, unsigned char *handler) -{ - FILE *pop = popen(handler, "r"); - - if (pop) { - int fd = fileno(pop); - - if (fd > 0) { - struct session *ses = type_query->ses; - unsigned char buf[48]; - - snprintf(buf, 48, "file:///dev/fd/%d", fd); - goto_url(ses, buf); - } - } -} static void tp_open(struct type_query *type_query) @@ -1011,7 +1016,7 @@ tp_open(struct type_query *type_query) if (handler) { if (type_query->copiousoutput) - read_from_popen(type_query, handler); + read_from_popen(type_query->ses, handler); else exec_on_terminal(type_query->ses->tab->term, handler, "", !!type_query->block);