Implement 'cd' and handle pipes on quoted commands
This commit is contained in:
parent
f1e42d9448
commit
c05c773431
|
@ -291,7 +291,7 @@ R_API int r_core_run_script (RCore *core, const char *file) {
|
|||
ret = r_core_cmd_lines (core, out);
|
||||
free (out);
|
||||
}
|
||||
return R_TRUE;;
|
||||
return ret;
|
||||
}
|
||||
if (r_parse_is_c_file (file)) {
|
||||
char *out = r_parse_c_file (file);
|
||||
|
@ -803,10 +803,13 @@ static int r_core_cmd_subst_i(RCore *core, char *cmd) {
|
|||
break;
|
||||
case '"':
|
||||
for (cmd++; *cmd; ) {
|
||||
int pipefd;
|
||||
ut64 oseek = UT64_MAX;
|
||||
char *line, *p = find_eoq (cmd);
|
||||
if (p) {
|
||||
if (p && *p) {
|
||||
*p = 0;
|
||||
// SKIPSPACES in p+1
|
||||
while (IS_WHITESPACE (p[1])) p++;
|
||||
if (p[1]=='@' || (p[1] && p[2]=='@')) {
|
||||
char *q = strchr (p+1, '"');
|
||||
if (q) *q = 0;
|
||||
|
@ -818,19 +821,36 @@ static int r_core_cmd_subst_i(RCore *core, char *cmd) {
|
|||
p = q;
|
||||
} else p = NULL;
|
||||
}
|
||||
if (p[1]=='>') {
|
||||
char *str = p+2;
|
||||
while (*str=='>') str++;
|
||||
while (IS_WHITESPACE (*str)) str++;
|
||||
r_cons_flush ();
|
||||
pipefd = r_cons_pipe_open (str, p[2]=='>');
|
||||
}
|
||||
line = strdup (cmd);
|
||||
line = r_str_replace (line, "\\\"", "\"", R_TRUE);
|
||||
r_cmd_call (core->rcmd, line);
|
||||
if (p[1]=='|') {
|
||||
str = p+2;
|
||||
while (IS_WHITESPACE (*str))str++;
|
||||
r_core_cmd_pipe (core, cmd, str);
|
||||
} else {
|
||||
r_cmd_call (core->rcmd, line);
|
||||
}
|
||||
free (line);
|
||||
if (oseek != UT64_MAX) {
|
||||
r_core_seek (core, oseek, 1);
|
||||
oseek = UT64_MAX;
|
||||
}
|
||||
if (pipefd != -1) {
|
||||
r_cons_flush ();
|
||||
r_cons_pipe_close (pipefd);
|
||||
}
|
||||
if (!p) break;
|
||||
*p = '"';
|
||||
cmd = p+1;
|
||||
} else {
|
||||
eprintf ("Missing \".");
|
||||
eprintf ("Missing \" in (%s).", cmd);
|
||||
return R_FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* radare - LGPL - Copyright 2009-2012 - pancake */
|
||||
/* radare - LGPL - Copyright 2009-2013 - pancake */
|
||||
|
||||
R_API void r_core_cmpwatch_free (RCoreCmpWatcher *w) {
|
||||
free (w->ndata);
|
||||
|
@ -174,6 +174,7 @@ static int cmd_cmp(void *data, const char *input) {
|
|||
FILE *fd;
|
||||
ut8 *buf;
|
||||
int ret;
|
||||
ut16 v16;
|
||||
ut32 v32;
|
||||
ut64 v64;
|
||||
|
||||
|
@ -218,14 +219,23 @@ static int cmd_cmp(void *data, const char *input) {
|
|||
radare_compare (core, core->block, buf, core->blocksize);
|
||||
free (buf);
|
||||
break;
|
||||
case 'q':
|
||||
v64 = (ut64) r_num_math (core->num, input+1);
|
||||
radare_compare (core, core->block, (ut8*)&v64, sizeof (v64));
|
||||
break;
|
||||
case 'd':
|
||||
while (input[1]==' ') input++;
|
||||
if (r_sandbox_chdir (input+1)==-1)
|
||||
eprintf ("Cannot chdir\n");
|
||||
break;
|
||||
case '2':
|
||||
v16 = (ut16) r_num_math (core->num, input+1);
|
||||
radare_compare (core, core->block, (ut8*)&v16, sizeof (v16));
|
||||
break;
|
||||
case '4':
|
||||
v32 = (ut32) r_num_math (core->num, input+1);
|
||||
radare_compare (core, core->block, (ut8*)&v32, sizeof (v32));
|
||||
break;
|
||||
case '8':
|
||||
v64 = (ut64) r_num_math (core->num, input+1);
|
||||
radare_compare (core, core->block, (ut8*)&v64, sizeof (v64));
|
||||
break;
|
||||
#if 0
|
||||
case 'c':
|
||||
radare_compare_code (
|
||||
|
@ -303,9 +313,9 @@ static int cmd_cmp(void *data, const char *input) {
|
|||
" c [string] Compares a plain with escaped chars string\n"
|
||||
" cc [at] [(at)] Compares in two hexdump columns of block size\n"
|
||||
//" cc [offset] Code bindiff current block against offset\n"
|
||||
" cd [value] Compare a doubleword from a math expression\n"
|
||||
" c4 [value] Compare a doubleword from a math expression\n"
|
||||
//" cD [file] Like above, but using radiff -b\n");
|
||||
" cq [value] Compare a quadword from a math expression\n"
|
||||
" c8 [value] Compare a quadword from a math expression\n"
|
||||
" cx [hexpair] Compare hexpair string\n"
|
||||
" cX [addr] Like 'cc' but using hexdiff output\n"
|
||||
" cf [file] Compare contents of file at current seek\n"
|
||||
|
|
|
@ -141,9 +141,8 @@ static int cmd_type(void *data, const char *input) {
|
|||
if (input[1]=='*') {
|
||||
eprintf ("TODO\n");
|
||||
} else {
|
||||
const char *ntr, *name = input + 1;
|
||||
const char *name = input + 1;
|
||||
if (*name==' ') name++;
|
||||
ntr = strchr (name, ' ');
|
||||
if (*name) {
|
||||
r_anal_type_del (core->anal, name);
|
||||
} else eprintf ("Usage: t- name\n"
|
||||
|
|
Loading…
Reference in New Issue