Fix ?*> dumping to screen ##shell

This commit is contained in:
pancake 2023-11-23 11:17:13 +01:00 committed by pancake
parent 32afc6e5d3
commit 4ceb8ebba3
2 changed files with 24 additions and 1 deletions

View File

@ -39,7 +39,7 @@ R_API int r_cons_pipe_open(const char *file, int fdn, int append) {
const int fd_flags = O_BINARY | O_RDWR | O_CREAT | (append? O_APPEND: O_TRUNC);
int fd = r_sandbox_open (targetFile, fd_flags, 0644);
if (fd == -1) {
R_LOG_ERROR ("Cannot open file '%s'", file);
R_LOG_ERROR ("ConsPipe cannot open file '%s'", file);
free (targetFile);
return -1;
}

View File

@ -4270,6 +4270,29 @@ escape_pipe:
ptr = strstr (cmd, "?*");
if (ptr && (ptr == cmd || ptr[-1] != '~')) {
char *pipechar = strchr (ptr, '>');
if (pipechar) {
*pipechar++ = 0;
const bool appendResult = *pipechar == '>';
const char *pipefile = r_str_trim_head_ro (appendResult? pipechar + 1: pipechar);
int pipefd = r_cons_pipe_open (pipefile, 1, appendResult);
if (pipefd != -1) {
int scr_color = -1;
bool pipecolor = r_config_get_b (core->config, "scr.color.pipe");
if (!pipecolor) {
scr_color = r_config_get_i (core->config, "scr.color");
r_config_set_i (core->config, "scr.color", COLOR_MODE_DISABLED);
}
ret = r_core_cmd_subst (core, cmd);
r_cons_flush ();
close (pipefd);
r_cons_pipe_close (pipefd);
if (!pipecolor) {
r_config_set_i (core->config, "scr.color", scr_color);
}
}
return ret;
}
ptr[0] = 0;
if (*cmd != '#') {
int detail = 0;