Skip to content

Commit

Permalink
Fix ?*> dumping to screen ##shell
Browse files Browse the repository at this point in the history
  • Loading branch information
radare authored and trufae committed Nov 23, 2023
1 parent 32afc6e commit 4ceb8eb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libr/cons/cpipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
23 changes: 23 additions & 0 deletions libr/core/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -4270,6 +4270,29 @@ static int r_core_cmd_subst_i(RCore *core, char *cmd, char *colon, bool *tmpseek

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;
Expand Down

0 comments on commit 4ceb8eb

Please sign in to comment.