Fix old math commands (#3828)

* core/cmd: Adjust math commands

* shell: make `?x` commands a parsing failure

We have moved the `?x` commands to `%x`, thus now no command should
start with `?`. This patch makes the parser fail to parse `?x`
strings.

* core/tui: use APIs in panels

* There's no `%q` anymore, use `%=`
This commit is contained in:
Riccardo Schirone 2023-09-14 02:53:25 +02:00 committed by GitHub
parent 08091e64b2
commit 9d68e9614f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
41 changed files with 455 additions and 438 deletions

View file

@ -10,7 +10,7 @@ conditional breakpoints are implemented in the following way:
1. ignore breakpoint at address `0x4000ce` for five times:
f times=5
(dec_times,f times=`?vi times-1`,?= times)
(dec_times,f times=`%vi times-1`,?= times)
db @ 0x4000ce
dbC .(dec_times) @ 0x4000ce
dc
@ -18,7 +18,7 @@ conditional breakpoints are implemented in the following way:
2. execute until rax==0x31c0 at address `0x4000ce`
e cmd.hitinfo=0
(break_rax,f reg_rax=`dr rax`,f test=`?vi reg_rax-0x31c0`,?= test)
(break_rax,f reg_rax=`dr rax`,f test=`%vi reg_rax-0x31c0`,?= test)
db @ 0x4000ce
dbC .(break_rax) @ 0x4000ce
dc

46
doc/hud
View file

@ -1,10 +1,10 @@
add comment;?i Comment;CC `ys`
list comments;CC;?ik
change block size;?i block size;b `ys`
add comment;%i Comment;CC `ys`
list comments;CC;%ik
change block size;%i block size;b `ys`
analyze all;aa
analyze function;af
analyze preludes;ap
continue process execution;dc;?i
continue process execution;dc;%i
disable colors;e scr.color=0
enable colors (ANSI 16);e scr.color=1
enable colors (256);e scr.color=2
@ -12,27 +12,27 @@ enable colors (16M);e scr.color=3
randomize colors;ecr
hide bytes in disassembly;e asm.bytes=false
show bytes in disassembly;e asm.bytes=true
list imports ;ii;?ik
list sections;iS;?ik
list symbols;is;?ik
list processes;dp*;?ik
run command;?i cmd;`ys`;?ik
list imports ;ii;%ik
list sections;iS;%ik
list symbols;is;%ik
list processes;dp*;%ik
run command;%i cmd;`ys`;%ik
seek to entrypoint;s entry0
seek to main;s main
set breakpoint;db;?i new breakpoint address;db `ys`
remove breakpoint ?i delete breakpoint at given address;db-`ys`
show backtrace;dbt;?ik
set breakpoint;db;%i new breakpoint address;db `ys`
remove breakpoint %i delete breakpoint at given address;db-`ys`
show backtrace;dbt;%ik
show bytes in disassembly;e asm.bytes=1
show debugger register values;dr;?ik
show process memory maps;dm;?ik
step instruction;sr PC;pd 1;ds;?ik
step over call;sr PC;pd 1;dso;?ik
write string;?i string;w `ys`
write hexadecimal data in current offset;?i hexpairs;wx `ys`
xor current block with hexpair key;?i hexpair key;wox `ys`
show debugger register values;dr;%ik
show process memory maps;dm;%ik
step instruction;sr PC;pd 1;ds;%ik
step over call;sr PC;pd 1;dso;%ik
write string;%i string;w `ys`
write hexadecimal data in current offset;%i hexpairs;wx `ys`
xor current block with hexpair key;%i hexpair key;wox `ys`
edit eval configuration;Veq
calculator;?i enter math expression;? `ys`;?ik
calculator;%i enter math expression;? `ys`;%ik
disassemble 1024 bytes and pipe to less(1);b 1024;pd|less -R
rename function;?i New name;afn `ys`
set flag;?i Flag name;f `ys`
unset flag;?i Flag name to delete;f-`ys`
rename function;%i New name;afn `ys`
set flag;%i Flag name;f `ys`
unset flag;%i Flag name to delete;f-`ys`

View file

@ -1461,7 +1461,7 @@ static int mips_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8
// TODO: currently there is no way for the macro to get access to this register
op->src[0] = rz_analysis_value_new();
op->src[0]->reg = rz_reg_get(analysis->reg, mips_reg_decode(rs), RZ_REG_TYPE_GPR);
op->val = imm; // Beware: this one is signed... use `?vi $v`
op->val = imm; // Beware: this one is signed... use `%vi $v`
if (rs == 0) {
insn.id = MIPS_INS_LI;
snprintf((char *)insn.i_reg.imm, REG_BUF_MAX, "0x%" PFMT32x, imm);

View file

@ -39,12 +39,12 @@ def walk_back_until(addr, pattern, min_addr):
def carve_trap_num(addr, flag):
saved_seek = r.cmd("?v $$")
saved_seek = r.cmd("%v $$")
r.cmd("e io.cache=true")
r.cmd("e emu.write=true")
r.cmd("aei")
r.cmd("aeim")
min_addr = int(r.cmd("?v " + flag), 0)
min_addr = int(r.cmd("%v " + flag), 0)
emu_start = walk_back_until(addr - 4, r"^b|^ret|^invalid", min_addr)
r.cmd("s " + str(emu_start))
obj = r.cmd("aefa 0x%08x~[0]:0" % addr)

View file

@ -68,7 +68,7 @@ static void guess_data_free(struct guess_data_t *g) {
/**
* Modify the input in \p buf to add additional characters, trying to detect
* what token could go in the current position of the buffer. For example, to
* detect that a CMD_ID is expected at * `?e $(<TAB>`, you could try inserting
* detect that a CMD_ID is expected at `echo $(<TAB>`, you could try inserting
* a letter and see what would be the new syntax tree.
*/
static struct guess_data_t *guess_next_autocmplt_token(RzCore *core, RzLineBuffer *buf, const char *fake_text, size_t offset) {

View file

@ -102,7 +102,6 @@ RZ_API void rz_core_bin_export_info(RzCore *core, int mode) {
char *k = sdbkv_key(kv);
char *v = sdbkv_value(kv);
char *dup = strdup(k);
// printf ("?e (%s) (%s)\n", k, v);
if ((flagname = strstr(dup, ".offset"))) {
*flagname = 0;
flagname = dup;

View file

@ -3264,7 +3264,7 @@ RZ_API int rz_core_config_init(RzCore *core) {
SETPREF("cfg.user", rz_sys_whoami(buf), "Set current username/pid");
SETCB("cfg.fortunes", "true", &cb_cfg_fortunes, "If enabled show tips at start");
SETCB("cfg.fortunes.file", "tips", &cb_cfg_fortunes_file, "Type of fortunes to show (tips, fun)");
SETBPREF("cfg.fortunes.clippy", "false", "Use ?E instead of ?e");
SETBPREF("cfg.fortunes.clippy", "false", "Use 'clippy' instead of 'echo'");
SETPREF("cfg.prefixdump", "dump", "Filename prefix for automated dumps");
SETBPREF("cfg.wseek", "false", "Seek after write");
SETICB("cfg.seek.histsize", 63, NULL, "Maximum size of the seek history");

View file

@ -617,9 +617,9 @@ static bool setbpint(RzCore *r, const char *mode, const char *sym) {
if (bp) {
bp->internal = true;
#if __linux__
bp->data = rz_str_newf("?e %s: %s", mode, sym);
bp->data = rz_str_newf("echo %s: %s", mode, sym);
#else
bp->data = rz_str_newf("?e %s: %s;ps@rdi", mode, sym);
bp->data = rz_str_newf("echo %s: %s;ps@rdi", mode, sym);
#endif
return true;
}

View file

@ -1879,7 +1879,7 @@ next2:
if (ptr[1] == '!') {
str = rz_core_cmd_str_pipe(core, ptr + 1);
} else {
// Color disabled when doing backticks ?e `pi 1`
// Color disabled when doing backticks echo `pi 1`
int ocolor = rz_config_get_i(core->config, "scr.color");
rz_config_set_i(core->config, "scr.color", 0);
core->cmd_in_backticks = true;
@ -3972,11 +3972,13 @@ DEFINE_HANDLE_TS_FCN_AND_SYMBOL(help_stmt) {
if (node_str_len >= 2 && !strcmp(node_string + node_str_len - 2, "?*")) {
node_string[node_str_len - 2] = 0;
const char *argv[2] = { NULL, node_string };
return rz_cmd_help_search_handler(state->core, 2, argv, RZ_OUTPUT_MODE_STANDARD);
int argc = node_str_len > 2 ? 2 : 1;
return rz_cmd_help_search_handler(state->core, argc, argv, RZ_OUTPUT_MODE_STANDARD);
} else if (node_str_len >= 3 && !strcmp(node_string + node_str_len - 3, "?*j")) {
node_string[node_str_len - 3] = 0;
const char *argv[2] = { NULL, node_string };
return rz_cmd_help_search_handler(state->core, 2, argv, RZ_OUTPUT_MODE_JSON);
int argc = node_str_len > 2 ? 2 : 1;
return rz_cmd_help_search_handler(state->core, argc, argv, RZ_OUTPUT_MODE_JSON);
}
TSNode command = ts_node_child_by_field_name(node, "command", strlen("command"));

View file

@ -31,7 +31,7 @@ struct rz_core_var core_vars[] = {
{ "$b", "block size" },
{ "$c", "get terminal width in character columns" },
{ "$Cn", "get nth call of function" },
{ "$D", "current debug map base address ?v $D @ rsp" },
{ "$D", "current debug map base address %v $D @ rsp" },
{ "$DB", "same as dbg.baddr, progam base address" },
{ "$DD", "current debug map size" },
{ "$Dn", "get nth data reference in function" },
@ -258,33 +258,23 @@ RZ_IPI RzCmdStatus rz_print_binary_handler(RzCore *core, int argc, const char **
}
RZ_IPI RzCmdStatus rz_base64_encode_handler(RzCore *core, int argc, const char **argv) {
char *buf = NULL;
for (int i = 1; i < argc; i++) {
const int buflen = (strlen(argv[i]) * 4) + 1;
buf = (char *)realloc((void *)buf, buflen * sizeof(char));
if (!buf) {
RZ_LOG_ERROR("core: Out of memory!");
return RZ_CMD_STATUS_ERROR;
}
rz_base64_encode(buf, (const ut8 *)argv[i], strlen(argv[i]));
rz_cons_println((const char *)buf);
char *buf = rz_base64_encode_dyn((ut8 *)argv[1], strlen(argv[1]));
if (!buf) {
RZ_LOG_ERROR("core: Out of memory!");
return RZ_CMD_STATUS_ERROR;
}
rz_cons_println(buf);
free(buf);
return RZ_CMD_STATUS_OK;
}
RZ_IPI RzCmdStatus rz_base64_decode_handler(RzCore *core, int argc, const char **argv) {
ut8 *buf = NULL;
for (int i = 1; i < argc; i++) {
const int buflen = (strlen(argv[i]) * 4) + 1;
buf = (ut8 *)realloc((void *)buf, buflen * sizeof(ut8));
if (!buf) {
RZ_LOG_ERROR("core: Out of memory!");
return RZ_CMD_STATUS_ERROR;
}
rz_base64_decode(buf, argv[i], -1);
rz_cons_println((const char *)buf);
ut8 *buf = rz_base64_decode_dyn(argv[1], -1);
if (!buf) {
RZ_LOG_ERROR("core: Out of memory!");
return RZ_CMD_STATUS_ERROR;
}
rz_cons_println((char *)buf);
free(buf);
return RZ_CMD_STATUS_OK;
}
@ -298,7 +288,7 @@ RZ_IPI RzCmdStatus rz_check_between_handler(RzCore *core, int argc, const char *
}
RZ_IPI RzCmdStatus rz_print_boundaries_prot_handler(RzCore *core, int argc, const char **argv) {
const char *mode = rz_str_trim_head_ro(argv[0]);
const char *mode = rz_str_trim_head_ro(argv[1]);
RzList *list = rz_core_get_boundaries_prot(core, -1, mode, "search");
if (!list) {
RZ_LOG_ERROR("core: Failed to get boundaries protection values in RzList");
@ -314,10 +304,8 @@ RZ_IPI RzCmdStatus rz_print_boundaries_prot_handler(RzCore *core, int argc, cons
}
RZ_IPI RzCmdStatus rz_print_djb2_hash_handler(RzCore *core, int argc, const char **argv) {
for (int i = 1; i < argc; i++) {
ut32 hash = (ut32)rz_str_djb2_hash(argv[i]);
rz_cons_printf("0x%08x\n", hash);
}
ut32 hash = (ut32)rz_str_djb2_hash(argv[1]);
rz_cons_printf("0x%08x\n", hash);
return RZ_CMD_STATUS_OK;
}
@ -345,10 +333,6 @@ RZ_IPI RzCmdStatus rz_num_to_units_handler(RzCore *core, int argc, const char **
}
RZ_IPI RzCmdStatus rz_set_last_eval_expr_handler(RzCore *core, int argc, const char **argv) {
if (core->num->dbz) {
RZ_LOG_ERROR("core: RzNum ERROR: Division by Zero\n");
return RZ_CMD_STATUS_ERROR;
}
rz_num_math(core->num, argv[1]);
return RZ_CMD_STATUS_OK;
}
@ -369,7 +353,7 @@ RZ_IPI RzCmdStatus rz_show_value_hex_handler(RzCore *core, int argc, const char
RZ_LOG_ERROR("core: RzNum ERROR: Division by Zero\n");
return RZ_CMD_STATUS_ERROR;
}
rz_cons_printf("0x%08" PFMT64x "\n", n); // differs from ?v here 0x%08
rz_cons_printf("0x%08" PFMT64x "\n", n); // differs from %v here 0x%08
return RZ_CMD_STATUS_OK;
}
@ -421,11 +405,6 @@ RZ_IPI RzCmdStatus rz_show_value_int_handler(RzCore *core, int argc, const char
return RZ_CMD_STATUS_OK;
}
RZ_IPI RzCmdStatus rz_set_core_num_value_handler(RzCore *core, int argc, const char **argv) {
rz_num_math(core->num, argv[1]);
return RZ_CMD_STATUS_OK;
}
RZ_IPI RzCmdStatus rz_compare_and_set_core_num_value_handler(RzCore *core, int argc, const char **argv) {
core->num->value = strcmp(argv[1], argv[2]);
return RZ_CMD_STATUS_OK;
@ -596,7 +575,7 @@ RZ_IPI RzCmdStatus rz_yank_hud_file_handler(RzCore *core, int argc, const char *
return RZ_CMD_STATUS_OK;
}
RZ_IPI RzCmdStatus rz_input_numerical_expr_handler(RzCore *core, int argc, const char **argv) {
static RzCmdStatus prompt_handler(RzCore *core, int argc, const char **argv, bool echo) {
if (!rz_cons_is_interactive()) {
RZ_LOG_ERROR("core: Not running in interactive mode\n");
return RZ_CMD_STATUS_WRONG_ARGS;
@ -611,27 +590,36 @@ RZ_IPI RzCmdStatus rz_input_numerical_expr_handler(RzCore *core, int argc, const
rz_core_yank_set_str(core, RZ_CORE_FOREIGN_ADDR, foo);
core->num->value = rz_num_math(core->num, foo);
rz_cons_set_raw(0);
if (echo) {
rz_cons_printf("%s\n", foo);
}
return RZ_CMD_STATUS_OK;
}
RZ_IPI RzCmdStatus rz_input_prompt_handler(RzCore *core, int argc, const char **argv) {
return prompt_handler(core, argc, argv, false);
}
RZ_IPI RzCmdStatus rz_input_prompt_echo_handler(RzCore *core, int argc, const char **argv) {
return prompt_handler(core, argc, argv, true);
}
static RzCmdStatus yesno_handler(RzCore *core, int argc, const char **argv, const char *yn) {
if (!rz_cons_is_interactive()) {
RZ_LOG_ERROR("core: Not running in interactive mode\n");
return RZ_CMD_STATUS_WRONG_ARGS;
}
core->num->value = rz_cons_yesno(0, "%s? (%s) ", argv[1], yn);
rz_cons_set_raw(0);
return RZ_CMD_STATUS_OK;
}
RZ_IPI RzCmdStatus rz_input_yesno_no_handler(RzCore *core, int argc, const char **argv) {
if (!rz_cons_is_interactive()) {
RZ_LOG_ERROR("core: Not running in interactive mode\n");
return RZ_CMD_STATUS_WRONG_ARGS;
}
core->num->value = rz_cons_yesno(0, "%s? (y/N)", argv[1]);
rz_cons_set_raw(0);
return RZ_CMD_STATUS_OK;
return yesno_handler(core, argc, argv, "y/N");
}
RZ_IPI RzCmdStatus rz_input_yesno_yes_handler(RzCore *core, int argc, const char **argv) {
if (!rz_cons_is_interactive()) {
RZ_LOG_ERROR("core: Not running in interactive mode\n");
return RZ_CMD_STATUS_WRONG_ARGS;
}
core->num->value = rz_cons_yesno(0, "%s? (Y/n)", argv[1]);
rz_cons_set_raw(0);
return RZ_CMD_STATUS_OK;
return yesno_handler(core, argc, argv, "Y/n");
}
RZ_IPI RzCmdStatus rz_input_any_key_handler(RzCore *core, int argc, const char **argv) {

View file

@ -2399,7 +2399,7 @@ static inline char *__refs(RzCore *core, ut64 x) {
return refs;
}
static bool cmd_pxr(RzCore *core, int len, RzCmdStateOutput *state, int wordsize, const char *query) {
static bool cmd_pxr(RzCore *core, ut64 at, int len, RzCmdStateOutput *state, int wordsize, const char *query) {
if (!len) {
return true;
}
@ -2422,7 +2422,7 @@ static bool cmd_pxr(RzCore *core, int len, RzCmdStateOutput *state, int wordsize
rz_table_add_column(t, n, "value", 0);
rz_table_add_column(t, s, "refs", 0);
for (ut64 i = 0; i + wordsize < end; i += wordsize) {
ut64 addr = core->offset + i;
ut64 addr = at + i;
ut64 val = rz_read_ble(buf + i, be, bitsize);
char *refs = __refs(core, val);
rz_table_add_rowf(t, "xxs", addr, val, refs);
@ -2434,7 +2434,7 @@ static bool cmd_pxr(RzCore *core, int len, RzCmdStateOutput *state, int wordsize
const int hex_depth = (int)rz_config_get_i(core->config, "hex.depth");
pj_a(pj);
for (ut64 i = 0; i + wordsize < end; i += wordsize) {
ut64 addr = core->offset + i;
ut64 addr = at + i;
ut64 val = rz_read_ble(buf + i, be, bitsize);
pj_o(pj);
pj_kn(pj, "addr", addr);
@ -2459,7 +2459,7 @@ static bool cmd_pxr(RzCore *core, int len, RzCmdStateOutput *state, int wordsize
}
} else if (mode == RZ_OUTPUT_MODE_RIZIN) {
for (ut64 i = 0; i + wordsize < end; i += wordsize) {
ut64 addr = core->offset + i;
ut64 addr = at + i;
ut64 val = rz_read_ble(buf + i, be, bitsize);
rz_strbuf_appendf(sb, "f pxr.%" PFMT64x " @ 0x%" PFMT64x "\n", val, addr);
}
@ -3458,7 +3458,7 @@ RZ_IPI RzCmdStatus rz_print_hexword_references_common_handler(RzCore *core, int
case 2:
case 4:
case 8:
cmd_pxr(core, len, state, wordsize, query);
cmd_pxr(core, core->offset, len, state, wordsize, query);
break;
default:
rz_warn_if_reached();
@ -5523,13 +5523,38 @@ RZ_IPI RzCmdStatus rz_print_columns_disassembly_handler(RzCore *core, int argc,
return RZ_CMD_STATUS_OK;
}
static void print_stack(RzCore *core) {
RzCmdStateOutput so;
ut64 sp_addr = rz_core_reg_getv_by_role_or_name(core, "SP");
if (rz_config_get_b(core->config, "dbg.slow")) {
rz_cmd_state_output_init(&so, RZ_OUTPUT_MODE_STANDARD);
int wordsize = rz_analysis_get_address_bits(core->analysis) / 8;
cmd_pxr(core, sp_addr, 128, &so, wordsize, NULL);
rz_cmd_state_output_print(&so);
rz_cmd_state_output_fini(&so);
} else if (rz_config_get_b(core->config, "stack.bytes")) {
char *string = rz_core_print_hexdump_or_hexdiff_str(core, RZ_OUTPUT_MODE_STANDARD, sp_addr, 128, false);
if (!string) {
RZ_LOG_ERROR("fail to print hexdump at 0x%" PFMT64x "\n", sp_addr);
return; // TODO: free stuff
}
rz_cons_print(string);
} else if (core->rasm->bits == 64) {
rz_core_print_dump(core, RZ_OUTPUT_MODE_STANDARD, sp_addr, 8, 128, RZ_CORE_PRINT_FORMAT_TYPE_HEXADECIMAL);
} else if (core->rasm->bits == 32) {
rz_core_print_dump(core, RZ_OUTPUT_MODE_STANDARD, sp_addr, 4, 128, RZ_CORE_PRINT_FORMAT_TYPE_HEXADECIMAL);
}
rz_cmd_state_output_init(&so, RZ_OUTPUT_MODE_STANDARD);
core_disassembly(core, core->blocksize, 0, &so, false);
rz_cmd_state_output_fini(&so);
}
RZ_IPI RzCmdStatus rz_print_columns_debug_handler(RzCore *core, int argc, const char **argv) {
if (!rz_config_get_b(core->config, "cfg.debug")) {
RZ_LOG_ERROR("Command works only in debug mode\n");
return RZ_CMD_STATUS_ERROR;
}
int h, w = rz_cons_get_size(&h);
int i;
int rows = h - 2;
int obsz = core->blocksize;
int user_rows = argc > 1 ? rz_num_math(core->num, argv[1]) : -1;
@ -5549,32 +5574,32 @@ RZ_IPI RzCmdStatus rz_print_columns_debug_handler(RzCore *core, int argc, const
ut64 osek = core->offset;
c->color = rz_config_get_i(core->config, "scr.color");
rz_core_block_size(core, rows * 32);
char *cmd = NULL;
int columns = 2;
for (i = 0; i < columns; i++) {
switch (i) {
case 0:
(void)rz_cons_canvas_gotoxy(c, 0, 0);
// TODO: Use the API directly
cmd = rz_str_newf("dr; ?e; ?e backtrace:; dbt");
break;
case 1:
(void)rz_cons_canvas_gotoxy(c, 28, 0);
// TODO: Use the API directly
// cmd = rz_str_newf ("pxw 128@r:SP;pd@r:PC");
cmd = rz_str_newf("%s 128 @r:SP; pd @ 0x%" PFMT64x, rz_core_print_stack_command(core), osek);
break;
}
char *dis = rz_core_cmd_str(core, cmd);
rz_cons_canvas_write(c, dis);
free(cmd);
free(dis);
}
// Left column
RzCmdStateOutput so;
(void)rz_cons_canvas_gotoxy(c, 0, 0);
rz_cons_push();
rz_debug_regs_args_handler(core, 0, NULL, RZ_OUTPUT_MODE_STANDARD);
rz_cons_print("\nbacktrace:\n");
rz_cmd_state_output_init(&so, RZ_OUTPUT_MODE_STANDARD);
rz_cmd_debug_display_bt_handler(core, 0, NULL, &so);
rz_cmd_state_output_print(&so);
rz_cmd_state_output_fini(&so);
rz_cons_canvas_write(c, rz_cons_get_buffer());
rz_cons_pop();
// Right column
(void)rz_cons_canvas_gotoxy(c, RZ_MAX(w / 3, 28), 0);
rz_cons_push();
print_stack(core);
rz_cons_canvas_write(c, rz_cons_get_buffer());
rz_cons_pop();
rz_core_block_size(core, obsz);
rz_core_seek(core, osek, true);
rz_cons_canvas_print(c);
rz_cons_canvas_free(c);
if (asm_minicols) {
rz_config_set(core->config, "asm.offset", o_ao);
rz_config_set(core->config, "asm.bytes", o_ab);

View file

@ -61,7 +61,7 @@ commands:
- name: Usage example
entries:
- text: "Example of a condition"
comment: "?v rax-0x0"
comment: "%v rax-0x0"
- name: dbd
summary: Disable breakpoint at current offset
cname: cmd_debug_disable_bp

View file

@ -119,7 +119,6 @@ static const RzCmdDescArg print_djb2_hash_args[2];
static const RzCmdDescArg print_bitstring_args[3];
static const RzCmdDescArg eval_expr_print_octal_args[2];
static const RzCmdDescArg num_to_units_args[2];
static const RzCmdDescArg set_last_eval_expr_args[2];
static const RzCmdDescArg show_value_args[2];
static const RzCmdDescArg show_value_hex_args[2];
static const RzCmdDescArg show_value_i1_args[2];
@ -127,7 +126,7 @@ static const RzCmdDescArg show_value_i2_args[2];
static const RzCmdDescArg show_value_i4_args[2];
static const RzCmdDescArg show_value_i8_args[2];
static const RzCmdDescArg show_value_int_args[2];
static const RzCmdDescArg set_core_num_value_args[2];
static const RzCmdDescArg set_last_eval_expr_args[2];
static const RzCmdDescArg compare_and_set_core_num_value_args[3];
static const RzCmdDescArg exec_cmd_if_core_num_value_positive_args[2];
static const RzCmdDescArg exec_cmd_if_core_num_value_negative_args[2];
@ -142,7 +141,8 @@ static const RzCmdDescArg generate_sequence_args[4];
static const RzCmdDescArg phys2virt_args[2];
static const RzCmdDescArg virt2phys_args[2];
static const RzCmdDescArg yank_hud_file_args[2];
static const RzCmdDescArg input_numerical_expr_args[2];
static const RzCmdDescArg input_prompt_args[2];
static const RzCmdDescArg input_prompt_echo_args[2];
static const RzCmdDescArg input_yesno_no_args[2];
static const RzCmdDescArg input_yesno_yes_args[2];
static const RzCmdDescArg input_yank_hud_args[2];
@ -1042,8 +1042,8 @@ static const RzCmdDescHelp tasks_wait_help = {
static const RzCmdDescDetailEntry oparen__Examples_detail_entries[] = {
{ .text = "(", .arg_str = "", .comment = "List defined macros" },
{ .text = "(", .arg_str = "foo; ?e Disassemble 10 bytes at 0x10000; pd 10 @ 0x10000)", .comment = "Define a new macro 'foo', which executes `?` followed by `pd` when called." },
{ .text = "(", .arg_str = "foo a b; ?e Disassemble ${a} bytes at ${b}; pd ${a} @ ${b})", .comment = "Define a new macro 'foo' with two arguments. ${a}/${b} are replaced before execution." },
{ .text = "(", .arg_str = "foo; echo Disassemble 10 bytes at 0x10000; pd 10 @ 0x10000)", .comment = "Define a new macro 'foo', which executes `?` followed by `pd` when called." },
{ .text = "(", .arg_str = "foo a b; echo Disassemble ${a} bytes at ${b}; pd ${a} @ ${b})", .comment = "Define a new macro 'foo' with two arguments. ${a}/${b} are replaced before execution." },
{ .text = "(-", .arg_str = "foo", .comment = "Remove previously defined macro named 'foo'" },
{ 0 },
};
@ -1482,7 +1482,7 @@ static const RzCmdDescArg calculate_expr_args[] = {
{ 0 },
};
static const RzCmdDescHelp calculate_expr_help = {
.summary = "Evaluate given numerical expression",
.summary = "Evaluate numerical expression <expr>",
.args = calculate_expr_args,
};
@ -1533,16 +1533,13 @@ static const RzCmdDescArg generate_random_number_args[] = {
{ 0 },
};
static const RzCmdDescHelp generate_random_number_help = {
.summary = "Generate random number",
.summary = "Generate a random number between <lowlimit> and <uplimit>",
.args = generate_random_number_args,
};
static const RzCmdDescHelp perc_b_help = {
.summary = "Base64 encode/decode and print binary commands",
};
static const RzCmdDescArg print_binary_args[] = {
{
.name = "num",
.name = "expr",
.type = RZ_CMD_ARG_TYPE_RZNUM,
.flags = RZ_CMD_ARG_FLAG_LAST,
@ -1550,7 +1547,7 @@ static const RzCmdDescArg print_binary_args[] = {
{ 0 },
};
static const RzCmdDescHelp print_binary_help = {
.summary = "Print binary format",
.summary = "Print <expr> in binary format",
.args = print_binary_args,
};
@ -1564,15 +1561,15 @@ static const RzCmdDescDetail base64_encode_details[] = {
};
static const RzCmdDescArg base64_encode_args[] = {
{
.name = "strs",
.name = "str",
.type = RZ_CMD_ARG_TYPE_STRING,
.flags = RZ_CMD_ARG_FLAG_ARRAY,
.flags = RZ_CMD_ARG_FLAG_LAST,
},
{ 0 },
};
static const RzCmdDescHelp base64_encode_help = {
.summary = "Base64 encode",
.summary = "Encode <str> in Base64",
.details = base64_encode_details,
.args = base64_encode_args,
};
@ -1587,15 +1584,15 @@ static const RzCmdDescDetail base64_decode_details[] = {
};
static const RzCmdDescArg base64_decode_args[] = {
{
.name = "b64strs",
.name = "str",
.type = RZ_CMD_ARG_TYPE_STRING,
.flags = RZ_CMD_ARG_FLAG_ARRAY,
.flags = RZ_CMD_ARG_FLAG_LAST,
},
{ 0 },
};
static const RzCmdDescHelp base64_decode_help = {
.summary = "Base64 decode. Maximum input length = 4*(strlen(str)).",
.summary = "Decode <str> from Base64",
.details = base64_decode_details,
.args = base64_decode_args,
};
@ -1620,7 +1617,7 @@ static const RzCmdDescArg check_between_args[] = {
{ 0 },
};
static const RzCmdDescHelp check_between_help = {
.summary = "Check if middle number is between the other two (first and last)",
.summary = "Check if <middle> number is between <first> and <last>",
.args = check_between_args,
};
@ -1659,15 +1656,15 @@ static const RzCmdDescDetail print_djb2_hash_details[] = {
};
static const RzCmdDescArg print_djb2_hash_args[] = {
{
.name = "strs",
.name = "<str>",
.type = RZ_CMD_ARG_TYPE_STRING,
.flags = RZ_CMD_ARG_FLAG_ARRAY,
.flags = RZ_CMD_ARG_FLAG_LAST,
},
{ 0 },
};
static const RzCmdDescHelp print_djb2_hash_help = {
.summary = "Print hash value of given input",
.summary = "Print hash value of string <str>",
.details = print_djb2_hash_details,
.args = print_djb2_hash_args,
};
@ -1713,7 +1710,7 @@ static const RzCmdDescDetail eval_expr_print_octal_details[] = {
};
static const RzCmdDescArg eval_expr_print_octal_args[] = {
{
.name = "input",
.name = "expr",
.type = RZ_CMD_ARG_TYPE_RZNUM,
.flags = RZ_CMD_ARG_FLAG_LAST,
@ -1721,14 +1718,14 @@ static const RzCmdDescArg eval_expr_print_octal_args[] = {
{ 0 },
};
static const RzCmdDescHelp eval_expr_print_octal_help = {
.summary = "Evaluate expression and print value in octal.",
.summary = "Print <expr> in octal format",
.details = eval_expr_print_octal_details,
.args = eval_expr_print_octal_args,
};
static const RzCmdDescArg num_to_units_args[] = {
{
.name = "input",
.name = "expr",
.type = RZ_CMD_ARG_TYPE_RZNUM,
.flags = RZ_CMD_ARG_FLAG_LAST,
@ -1736,39 +1733,16 @@ static const RzCmdDescArg num_to_units_args[] = {
{ 0 },
};
static const RzCmdDescHelp num_to_units_help = {
.summary = "Convert evaluated numbers/expressions to K, M, G, T etc... units",
.summary = "Convert <expr> to K, M, G, T etc... units",
.args = num_to_units_args,
};
static const RzCmdDescDetailEntry set_last_eval_expr_Examples_detail_entries[] = {
{ .text = "%q", .arg_str = " 123", .comment = "This will set $?. Then commands like ??x can be used to do some task by checking whether $? holds positive value or not." },
{ 0 },
};
static const RzCmdDescDetail set_last_eval_expr_details[] = {
{ .name = "Examples", .entries = set_last_eval_expr_Examples_detail_entries },
{ 0 },
};
static const RzCmdDescArg set_last_eval_expr_args[] = {
{
.name = "input",
.type = RZ_CMD_ARG_TYPE_RZNUM,
.flags = RZ_CMD_ARG_FLAG_LAST,
},
{ 0 },
};
static const RzCmdDescHelp set_last_eval_expr_help = {
.summary = "Update $? (last evaluated expression) without printing anything",
.details = set_last_eval_expr_details,
.args = set_last_eval_expr_args,
};
static const RzCmdDescHelp perc_v_help = {
.summary = "Show value commands",
};
static const RzCmdDescArg show_value_args[] = {
{
.name = "input",
.name = "expr",
.type = RZ_CMD_ARG_TYPE_RZNUM,
.flags = RZ_CMD_ARG_FLAG_LAST,
.optional = true,
@ -1777,13 +1751,13 @@ static const RzCmdDescArg show_value_args[] = {
{ 0 },
};
static const RzCmdDescHelp show_value_help = {
.summary = "Show last or currently evaluated expression",
.summary = "Show last expression ($?) or currently evaluated <expr>",
.args = show_value_args,
};
static const RzCmdDescArg show_value_hex_args[] = {
{
.name = "input",
.name = "expr",
.type = RZ_CMD_ARG_TYPE_RZNUM,
.flags = RZ_CMD_ARG_FLAG_LAST,
.optional = true,
@ -1792,13 +1766,13 @@ static const RzCmdDescArg show_value_hex_args[] = {
{ 0 },
};
static const RzCmdDescHelp show_value_hex_help = {
.summary = "Show last or currently evaluated expression in hex",
.summary = "Show last expression ($?) or currently evaluated <expr> in hex",
.args = show_value_hex_args,
};
static const RzCmdDescArg show_value_i1_args[] = {
{
.name = "input",
.name = "expr",
.type = RZ_CMD_ARG_TYPE_RZNUM,
.flags = RZ_CMD_ARG_FLAG_LAST,
.optional = true,
@ -1807,13 +1781,13 @@ static const RzCmdDescArg show_value_i1_args[] = {
{ 0 },
};
static const RzCmdDescHelp show_value_i1_help = {
.summary = "Show last or currently evaluated expression as 1 byte integer",
.summary = "Show last expression ($?) or currently evaluated <expr> as 1 byte integer",
.args = show_value_i1_args,
};
static const RzCmdDescArg show_value_i2_args[] = {
{
.name = "input",
.name = "expr",
.type = RZ_CMD_ARG_TYPE_RZNUM,
.flags = RZ_CMD_ARG_FLAG_LAST,
.optional = true,
@ -1822,13 +1796,13 @@ static const RzCmdDescArg show_value_i2_args[] = {
{ 0 },
};
static const RzCmdDescHelp show_value_i2_help = {
.summary = "Show last or currently evaluated expression as 2 byte integer",
.summary = "Show last expression ($?) or currently evaluated <expr> as 2 bytes integer",
.args = show_value_i2_args,
};
static const RzCmdDescArg show_value_i4_args[] = {
{
.name = "input",
.name = "expr",
.type = RZ_CMD_ARG_TYPE_RZNUM,
.flags = RZ_CMD_ARG_FLAG_LAST,
.optional = true,
@ -1837,13 +1811,13 @@ static const RzCmdDescArg show_value_i4_args[] = {
{ 0 },
};
static const RzCmdDescHelp show_value_i4_help = {
.summary = "Show last or currently evaluated expression as 4 byte integer",
.summary = "Show last expression ($?) or currently evaluated <expr> as 4 bytes integer",
.args = show_value_i4_args,
};
static const RzCmdDescArg show_value_i8_args[] = {
{
.name = "input",
.name = "expr",
.type = RZ_CMD_ARG_TYPE_RZNUM,
.flags = RZ_CMD_ARG_FLAG_LAST,
.optional = true,
@ -1852,13 +1826,13 @@ static const RzCmdDescArg show_value_i8_args[] = {
{ 0 },
};
static const RzCmdDescHelp show_value_i8_help = {
.summary = "Show last or currently evaluated expression as 8 byte integer",
.summary = "Show last expression ($?) or currently evaluated <expr> as 8 bytes integer",
.args = show_value_i8_args,
};
static const RzCmdDescArg show_value_int_args[] = {
{
.name = "input",
.name = "expr",
.type = RZ_CMD_ARG_TYPE_RZNUM,
.flags = RZ_CMD_ARG_FLAG_LAST,
.optional = true,
@ -1867,22 +1841,31 @@ static const RzCmdDescArg show_value_int_args[] = {
{ 0 },
};
static const RzCmdDescHelp show_value_int_help = {
.summary = "Show last or currently evaluated expression as integer",
.summary = "Show last expression ($?) or currently evaluated <expr> as integer",
.args = show_value_int_args,
};
static const RzCmdDescArg set_core_num_value_args[] = {
static const RzCmdDescDetailEntry set_last_eval_expr_Examples_detail_entries[] = {
{ .text = "%q", .arg_str = " 123", .comment = "This will set $?. Then commands like %+, %-, etc. can be used to do some task by checking whether $? holds positive value or not." },
{ 0 },
};
static const RzCmdDescDetail set_last_eval_expr_details[] = {
{ .name = "Examples", .entries = set_last_eval_expr_Examples_detail_entries },
{ 0 },
};
static const RzCmdDescArg set_last_eval_expr_args[] = {
{
.name = "input",
.name = "expr",
.type = RZ_CMD_ARG_TYPE_RZNUM,
.flags = RZ_CMD_ARG_FLAG_LAST,
},
{ 0 },
};
static const RzCmdDescHelp set_core_num_value_help = {
.summary = "Replace the value of last evalued expression with given value",
.args = set_core_num_value_args,
static const RzCmdDescHelp set_last_eval_expr_help = {
.summary = "Update $? (last evaluated expression) with <expr>, without printing anything",
.details = set_last_eval_expr_details,
.args = set_last_eval_expr_args,
};
static const RzCmdDescDetailEntry compare_and_set_core_num_value_Examples_detail_entries[] = {
@ -1908,7 +1891,7 @@ static const RzCmdDescArg compare_and_set_core_num_value_args[] = {
{ 0 },
};
static const RzCmdDescHelp compare_and_set_core_num_value_help = {
.summary = "Compare two given strings and set $? register to cmp result",
.summary = "Compare strings <str1> and <str2> and set $? register to cmp result",
.details = compare_and_set_core_num_value_details,
.args = compare_and_set_core_num_value_args,
};
@ -1933,7 +1916,7 @@ static const RzCmdDescArg exec_cmd_if_core_num_value_positive_args[] = {
{ 0 },
};
static const RzCmdDescHelp exec_cmd_if_core_num_value_positive_help = {
.summary = "Execute given command if $? register is greater than 0",
.summary = "Execute command <cmd> if $? register is greater than 0",
.details = exec_cmd_if_core_num_value_positive_details,
.args = exec_cmd_if_core_num_value_positive_args,
};
@ -1958,7 +1941,7 @@ static const RzCmdDescArg exec_cmd_if_core_num_value_negative_args[] = {
{ 0 },
};
static const RzCmdDescHelp exec_cmd_if_core_num_value_negative_help = {
.summary = "Execute given command if $? register is less than 0",
.summary = "Execute command <cmd> if $? register is less than 0",
.details = exec_cmd_if_core_num_value_negative_details,
.args = exec_cmd_if_core_num_value_negative_args,
};
@ -1973,7 +1956,7 @@ static const RzCmdDescArg exec_cmd_if_core_num_value_zero_args[] = {
{ 0 },
};
static const RzCmdDescHelp exec_cmd_if_core_num_value_zero_help = {
.summary = "Execute command if result of last numeric expression evaluation (related) command was 0",
.summary = "Execute command <cmd> if $? is 0",
.args = exec_cmd_if_core_num_value_zero_args,
};
@ -1987,7 +1970,7 @@ static const RzCmdDescArg exec_cmd_if_core_num_value_nonzero_args[] = {
{ 0 },
};
static const RzCmdDescHelp exec_cmd_if_core_num_value_nonzero_help = {
.summary = "Execute command if result of last numeric expression evaluation (related) command was not 0",
.summary = "Execute command <cmd> if $? is not 0",
.args = exec_cmd_if_core_num_value_nonzero_args,
};
@ -2001,7 +1984,7 @@ static const RzCmdDescArg calculate_string_length_args[] = {
{ 0 },
};
static const RzCmdDescHelp calculate_string_length_help = {
.summary = "Calculate length of string. Quite mode stores value in `$?` register.",
.summary = "Calculate length of string <str>. Quite mode stores value in `$?` register.",
.args = calculate_string_length_args,
};
@ -2015,7 +1998,7 @@ static const RzCmdDescArg calc_expr_show_hex_args[] = {
{ 0 },
};
static const RzCmdDescHelp calc_expr_show_hex_help = {
.summary = "Show evaluated expression in hex",
.summary = "Show evaluated expression <expr> in hex",
.args = calc_expr_show_hex_args,
};
@ -2084,14 +2067,15 @@ static const RzCmdDescArg generate_sequence_args[] = {
{ 0 },
};
static const RzCmdDescHelp generate_sequence_help = {
.summary = "Generate sequence of numbers (?s from to step)",
.summary = "Generate sequence of numbers from <start> to <stop> with <step> increments",
.args = generate_sequence_args,
};
static const RzCmdDescArg phys2virt_args[] = {
{
.name = "paddr",
.type = RZ_CMD_ARG_TYPE_NUM,
.type = RZ_CMD_ARG_TYPE_RZNUM,
.flags = RZ_CMD_ARG_FLAG_LAST,
.optional = true,
},
@ -2105,7 +2089,8 @@ static const RzCmdDescHelp phys2virt_help = {
static const RzCmdDescArg virt2phys_args[] = {
{
.name = "vaddr",
.type = RZ_CMD_ARG_TYPE_NUM,
.type = RZ_CMD_ARG_TYPE_RZNUM,
.flags = RZ_CMD_ARG_FLAG_LAST,
.optional = true,
},
@ -2133,22 +2118,37 @@ static const RzCmdDescHelp yank_hud_file_help = {
static const RzCmdDescHelp perc_i_help = {
.summary = "Input commands",
};
static const RzCmdDescArg input_numerical_expr_args[] = {
static const RzCmdDescArg input_prompt_args[] = {
{
.name = "vaddr",
.type = RZ_CMD_ARG_TYPE_NUM,
.name = "prompt",
.type = RZ_CMD_ARG_TYPE_STRING,
.flags = RZ_CMD_ARG_FLAG_LAST,
},
{ 0 },
};
static const RzCmdDescHelp input_numerical_expr_help = {
.summary = "Input numerical expression and store in $? register",
.args = input_numerical_expr_args,
static const RzCmdDescHelp input_prompt_help = {
.summary = "Input the <prompt> and save response in yank clipboard (`y` commands)",
.args = input_prompt_args,
};
static const RzCmdDescArg input_prompt_echo_args[] = {
{
.name = "prompt",
.type = RZ_CMD_ARG_TYPE_STRING,
.flags = RZ_CMD_ARG_FLAG_LAST,
},
{ 0 },
};
static const RzCmdDescHelp input_prompt_echo_help = {
.summary = "Input the <prompt>, save response in yank clipboard (`y` commands), and print it",
.args = input_prompt_echo_args,
};
static const RzCmdDescArg input_yesno_no_args[] = {
{
.name = "opt",
.name = "question",
.type = RZ_CMD_ARG_TYPE_STRING,
.flags = RZ_CMD_ARG_FLAG_LAST,
.optional = true,
@ -2157,13 +2157,13 @@ static const RzCmdDescArg input_yesno_no_args[] = {
{ 0 },
};
static const RzCmdDescHelp input_yesno_no_help = {
.summary = "Input YES/NO and store result in $? register",
.summary = "Input Yes/No <question> and store result in $? register (default No)",
.args = input_yesno_no_args,
};
static const RzCmdDescArg input_yesno_yes_args[] = {
{
.name = "opt",
.name = "question",
.type = RZ_CMD_ARG_TYPE_STRING,
.flags = RZ_CMD_ARG_FLAG_LAST,
.optional = true,
@ -2172,7 +2172,7 @@ static const RzCmdDescArg input_yesno_yes_args[] = {
{ 0 },
};
static const RzCmdDescHelp input_yesno_yes_help = {
.summary = "Input YES/NO and store result in $? register",
.summary = "Input Yes/No <question> and store result in $? register (default Yes)",
.args = input_yesno_yes_args,
};
@ -2189,12 +2189,13 @@ static const RzCmdDescArg input_yank_hud_args[] = {
.name = "path",
.type = RZ_CMD_ARG_TYPE_STRING,
.flags = RZ_CMD_ARG_FLAG_LAST,
.optional = true,
},
{ 0 },
};
static const RzCmdDescHelp input_yank_hud_help = {
.summary = "Yank HUD path and store result in $? register",
.summary = "Interactive HUD mode to find files in <path>",
.args = input_yank_hud_args,
};
@ -2208,21 +2209,21 @@ static const RzCmdDescArg input_msg_args[] = {
{ 0 },
};
static const RzCmdDescHelp input_msg_help = {
.summary = "Input message and display in console",
.summary = "Display <msg> in console and wait for key",
.args = input_msg_args,
};
static const RzCmdDescArg input_conditional_args[] = {
{
.name = "cond",
.type = RZ_CMD_ARG_TYPE_STRING,
.name = "expr",
.type = RZ_CMD_ARG_TYPE_RZNUM,
.flags = RZ_CMD_ARG_FLAG_LAST,
},
{ 0 },
};
static const RzCmdDescHelp input_conditional_help = {
.summary = "Input conditional and store result in $? register",
.summary = "Evaluate <expr>, store result in $? register and print true if <expr> != 0, false otherwise",
.args = input_conditional_args,
};
@ -7388,7 +7389,7 @@ static const RzCmdDescHelp cmd_debug_command_bp_help = {
};
static const RzCmdDescDetailEntry cmd_debug_add_cond_bp_Usage_space_example_detail_entries[] = {
{ .text = "Example of a condition", .arg_str = NULL, .comment = "?v rax-0x0" },
{ .text = "Example of a condition", .arg_str = NULL, .comment = "%v rax-0x0" },
{ 0 },
};
static const RzCmdDescDetail cmd_debug_add_cond_bp_details[] = {
@ -18762,12 +18763,13 @@ RZ_IPI void rzshell_cmddescs_init(RzCore *core) {
RzCmdDesc *generate_random_number_cd = rz_cmd_desc_argv_new(core->rcmd, cmd_math_cd, "%r", rz_generate_random_number_handler, &generate_random_number_help);
rz_warn_if_fail(generate_random_number_cd);
RzCmdDesc *perc_b_cd = rz_cmd_desc_group_new(core->rcmd, cmd_math_cd, "%b", rz_print_binary_handler, &print_binary_help, &perc_b_help);
rz_warn_if_fail(perc_b_cd);
RzCmdDesc *base64_encode_cd = rz_cmd_desc_argv_new(core->rcmd, perc_b_cd, "%b64", rz_base64_encode_handler, &base64_encode_help);
RzCmdDesc *print_binary_cd = rz_cmd_desc_argv_new(core->rcmd, cmd_math_cd, "%b", rz_print_binary_handler, &print_binary_help);
rz_warn_if_fail(print_binary_cd);
RzCmdDesc *base64_encode_cd = rz_cmd_desc_argv_new(core->rcmd, cmd_math_cd, "%b64", rz_base64_encode_handler, &base64_encode_help);
rz_warn_if_fail(base64_encode_cd);
RzCmdDesc *base64_decode_cd = rz_cmd_desc_argv_new(core->rcmd, perc_b_cd, "%b64-", rz_base64_decode_handler, &base64_decode_help);
RzCmdDesc *base64_decode_cd = rz_cmd_desc_argv_new(core->rcmd, cmd_math_cd, "%b64-", rz_base64_decode_handler, &base64_decode_help);
rz_warn_if_fail(base64_decode_cd);
RzCmdDesc *check_between_cd = rz_cmd_desc_argv_new(core->rcmd, cmd_math_cd, "%btw", rz_check_between_handler, &check_between_help);
@ -18788,9 +18790,6 @@ RZ_IPI void rzshell_cmddescs_init(RzCore *core) {
RzCmdDesc *num_to_units_cd = rz_cmd_desc_argv_new(core->rcmd, cmd_math_cd, "%u", rz_num_to_units_handler, &num_to_units_help);
rz_warn_if_fail(num_to_units_cd);
RzCmdDesc *set_last_eval_expr_cd = rz_cmd_desc_argv_new(core->rcmd, cmd_math_cd, "%q", rz_set_last_eval_expr_handler, &set_last_eval_expr_help);
rz_warn_if_fail(set_last_eval_expr_cd);
RzCmdDesc *perc_v_cd = rz_cmd_desc_group_new(core->rcmd, cmd_math_cd, "%v", rz_show_value_handler, &show_value_help, &perc_v_help);
rz_warn_if_fail(perc_v_cd);
RzCmdDesc *show_value_hex_cd = rz_cmd_desc_argv_new(core->rcmd, perc_v_cd, "%vx", rz_show_value_hex_handler, &show_value_hex_help);
@ -18811,8 +18810,8 @@ RZ_IPI void rzshell_cmddescs_init(RzCore *core) {
RzCmdDesc *show_value_int_cd = rz_cmd_desc_argv_new(core->rcmd, perc_v_cd, "%vi", rz_show_value_int_handler, &show_value_int_help);
rz_warn_if_fail(show_value_int_cd);
RzCmdDesc *set_core_num_value_cd = rz_cmd_desc_argv_new(core->rcmd, cmd_math_cd, "%=", rz_set_core_num_value_handler, &set_core_num_value_help);
rz_warn_if_fail(set_core_num_value_cd);
RzCmdDesc *set_last_eval_expr_cd = rz_cmd_desc_argv_new(core->rcmd, cmd_math_cd, "%=", rz_set_last_eval_expr_handler, &set_last_eval_expr_help);
rz_warn_if_fail(set_last_eval_expr_cd);
RzCmdDesc *compare_and_set_core_num_value_cd = rz_cmd_desc_argv_new(core->rcmd, cmd_math_cd, "%==", rz_compare_and_set_core_num_value_handler, &compare_and_set_core_num_value_help);
rz_warn_if_fail(compare_and_set_core_num_value_cd);
@ -18855,8 +18854,11 @@ RZ_IPI void rzshell_cmddescs_init(RzCore *core) {
RzCmdDesc *yank_hud_file_cd = rz_cmd_desc_argv_new(core->rcmd, cmd_math_cd, "%_", rz_yank_hud_file_handler, &yank_hud_file_help);
rz_warn_if_fail(yank_hud_file_cd);
RzCmdDesc *perc_i_cd = rz_cmd_desc_group_new(core->rcmd, cmd_math_cd, "%i", rz_input_numerical_expr_handler, &input_numerical_expr_help, &perc_i_help);
RzCmdDesc *perc_i_cd = rz_cmd_desc_group_new(core->rcmd, cmd_math_cd, "%i", rz_input_prompt_handler, &input_prompt_help, &perc_i_help);
rz_warn_if_fail(perc_i_cd);
RzCmdDesc *input_prompt_echo_cd = rz_cmd_desc_argv_new(core->rcmd, perc_i_cd, "%ie", rz_input_prompt_echo_handler, &input_prompt_echo_help);
rz_warn_if_fail(input_prompt_echo_cd);
RzCmdDesc *input_yesno_no_cd = rz_cmd_desc_argv_new(core->rcmd, perc_i_cd, "%in", rz_input_yesno_no_handler, &input_yesno_no_help);
rz_warn_if_fail(input_yesno_no_cd);

View file

@ -118,8 +118,6 @@ RZ_IPI RzCmdStatus rz_print_bitstring_handler(RzCore *core, int argc, const char
RZ_IPI RzCmdStatus rz_eval_expr_print_octal_handler(RzCore *core, int argc, const char **argv);
// "%u"
RZ_IPI RzCmdStatus rz_num_to_units_handler(RzCore *core, int argc, const char **argv);
// "%q"
RZ_IPI RzCmdStatus rz_set_last_eval_expr_handler(RzCore *core, int argc, const char **argv);
// "%v"
RZ_IPI RzCmdStatus rz_show_value_handler(RzCore *core, int argc, const char **argv);
// "%vx"
@ -135,7 +133,7 @@ RZ_IPI RzCmdStatus rz_show_value_i8_handler(RzCore *core, int argc, const char *
// "%vi"
RZ_IPI RzCmdStatus rz_show_value_int_handler(RzCore *core, int argc, const char **argv);
// "%="
RZ_IPI RzCmdStatus rz_set_core_num_value_handler(RzCore *core, int argc, const char **argv);
RZ_IPI RzCmdStatus rz_set_last_eval_expr_handler(RzCore *core, int argc, const char **argv);
// "%=="
RZ_IPI RzCmdStatus rz_compare_and_set_core_num_value_handler(RzCore *core, int argc, const char **argv);
// "%+"
@ -165,7 +163,9 @@ RZ_IPI RzCmdStatus rz_virt2phys_handler(RzCore *core, int argc, const char **arg
// "%_"
RZ_IPI RzCmdStatus rz_yank_hud_file_handler(RzCore *core, int argc, const char **argv);
// "%i"
RZ_IPI RzCmdStatus rz_input_numerical_expr_handler(RzCore *core, int argc, const char **argv);
RZ_IPI RzCmdStatus rz_input_prompt_handler(RzCore *core, int argc, const char **argv);
// "%ie"
RZ_IPI RzCmdStatus rz_input_prompt_echo_handler(RzCore *core, int argc, const char **argv);
// "%in"
RZ_IPI RzCmdStatus rz_input_yesno_no_handler(RzCore *core, int argc, const char **argv);
// "%iy"

View file

@ -112,10 +112,10 @@ commands:
arg_str: ""
comment: List defined macros
- text: (
arg_str: foo; ?e Disassemble 10 bytes at 0x10000; pd 10 @ 0x10000)
arg_str: foo; echo Disassemble 10 bytes at 0x10000; pd 10 @ 0x10000)
comment: Define a new macro 'foo', which executes `?` followed by `pd` when called.
- text: (
arg_str: foo a b; ?e Disassemble ${a} bytes at ${b}; pd ${a} @ ${b})
arg_str: foo a b; echo Disassemble ${a} bytes at ${b}; pd ${a} @ ${b})
comment: Define a new macro 'foo' with two arguments. ${a}/${b} are replaced before execution.
- text: (-
arg_str: foo

View file

@ -4,7 +4,7 @@
name: cmd_math
commands:
- name: "%"
summary: Evaluate given numerical expression
summary: Evaluate numerical expression <expr>
cname: calculate_expr
type: RZ_CMD_DESC_TYPE_ARGV_STATE
modes:
@ -30,7 +30,7 @@ commands:
cname: set_active_tab_next
args: []
- name: "%r"
summary: Generate random number
summary: Generate a random number between <lowlimit> and <uplimit>
cname: generate_random_number
args:
- name: lowlimit
@ -38,43 +38,37 @@ commands:
- name: uplimit
type: RZ_CMD_ARG_TYPE_RZNUM
- name: "%b"
summary: Base64 encode/decode and print binary commands
type: RZ_CMD_DESC_TYPE_GROUP
subcommands:
- name: "%b"
summary: Print binary format
cname: print_binary
args:
- name: num
type: RZ_CMD_ARG_TYPE_RZNUM
- name: "%b64"
summary: Base64 encode
cname: base64_encode
args:
- name: strs
type: RZ_CMD_ARG_TYPE_STRING
flags: RZ_CMD_ARG_FLAG_ARRAY
details:
- name: Examples
entries:
- text: "%b64"
arg_str: " ILoveRizin"
comment: (SUxvdmVSaXppbgo=) Encodes given string into base64
- name: "%b64-"
summary: Base64 decode. Maximum input length = 4*(strlen(str)).
cname: base64_decode
args:
- name: b64strs
type: RZ_CMD_ARG_TYPE_STRING
flags: RZ_CMD_ARG_FLAG_ARRAY
details:
- name: Examples
entries:
- text: "%b64- "
arg_str: SUxvdmVSaXppbgo=
comment: (ILoveRizin) Decodes given base64 string
summary: Print <expr> in binary format
cname: print_binary
args:
- name: expr
type: RZ_CMD_ARG_TYPE_RZNUM
- name: "%b64"
summary: Encode <str> in Base64
cname: base64_encode
args:
- name: str
type: RZ_CMD_ARG_TYPE_STRING
details:
- name: Examples
entries:
- text: "%b64"
arg_str: " ILoveRizin"
comment: (SUxvdmVSaXppbgo=) Encodes given string into base64
- name: "%b64-"
summary: Decode <str> from Base64
cname: base64_decode
args:
- name: str
type: RZ_CMD_ARG_TYPE_STRING
details:
- name: Examples
entries:
- text: "%b64- "
arg_str: SUxvdmVSaXppbgo=
comment: (ILoveRizin) Decodes given base64 string
- name: "%btw"
summary: Check if middle number is between the other two (first and last)
summary: Check if <middle> number is between <first> and <last>
cname: check_between
args:
- name: first
@ -103,12 +97,11 @@ commands:
arg_str: io.maps
comment: Prints boundaries of all io maps
- name: "%h"
summary: Print hash value of given input
summary: Print hash value of string <str>
cname: print_djb2_hash
args:
- name: strs
- name: <str>
type: RZ_CMD_ARG_TYPE_STRING
flags: RZ_CMD_ARG_FLAG_ARRAY
details:
- name: Examples
entries:
@ -138,10 +131,10 @@ commands:
arg_str: " 12 Hello"
comment: "LL (00110b selected : big-endian bitstring)"
- name: "%o"
summary: Evaluate expression and print value in octal.
summary: Print <expr> in octal format
cname: eval_expr_print_octal
args:
- name: input
- name: expr
type: RZ_CMD_ARG_TYPE_RZNUM
details:
- name: Examples
@ -153,16 +146,69 @@ commands:
arg_str: " 321"
comment: 0501 in octal
- name: "%u"
summary: "Convert evaluated numbers/expressions to K, M, G, T etc... units"
summary: "Convert <expr> to K, M, G, T etc... units"
cname: num_to_units
args:
- name: input
- name: expr
type: RZ_CMD_ARG_TYPE_RZNUM
- name: "%q"
summary: Update $? (last evaluated expression) without printing anything
- name: "%v"
summary: Show value commands
type: RZ_CMD_DESC_TYPE_GROUP
subcommands:
- name: "%v"
summary: Show last expression ($?) or currently evaluated <expr>
cname: show_value
args:
- name: expr
type: RZ_CMD_ARG_TYPE_RZNUM
optional: true
- name: "%vx"
summary: Show last expression ($?) or currently evaluated <expr> in hex
cname: show_value_hex
args:
- name: expr
type: RZ_CMD_ARG_TYPE_RZNUM
optional: true
- name: "%vi1"
summary: Show last expression ($?) or currently evaluated <expr> as 1 byte integer
cname: show_value_i1
args:
- name: expr
type: RZ_CMD_ARG_TYPE_RZNUM
optional: true
- name: "%vi2"
summary: Show last expression ($?) or currently evaluated <expr> as 2 bytes integer
cname: show_value_i2
args:
- name: expr
type: RZ_CMD_ARG_TYPE_RZNUM
optional: true
- name: "%vi4"
summary: Show last expression ($?) or currently evaluated <expr> as 4 bytes integer
cname: show_value_i4
args:
- name: expr
type: RZ_CMD_ARG_TYPE_RZNUM
optional: true
- name: "%vi8"
summary: Show last expression ($?) or currently evaluated <expr> as 8 bytes integer
cname: show_value_i8
args:
- name: expr
type: RZ_CMD_ARG_TYPE_RZNUM
optional: true
- name: "%vi"
summary: Show last expression ($?) or currently evaluated <expr> as integer
cname: show_value_int
args:
- name: expr
type: RZ_CMD_ARG_TYPE_RZNUM
optional: true
- name: "%="
summary: Update $? (last evaluated expression) with <expr>, without printing anything
cname: set_last_eval_expr
args:
- name: input
- name: expr
type: RZ_CMD_ARG_TYPE_RZNUM
details:
- name: Examples
@ -170,69 +216,10 @@ commands:
- text: "%q"
arg_str: " 123"
comment: >-
This will set $?. Then commands like ??x can be used to do some task
This will set $?. Then commands like %+, %-, etc. can be used to do some task
by checking whether $? holds positive value or not.
- name: "%v"
summary: Show value commands
type: RZ_CMD_DESC_TYPE_GROUP
subcommands:
- name: "%v"
summary: Show last or currently evaluated expression
cname: show_value
args:
- name: input
type: RZ_CMD_ARG_TYPE_RZNUM
optional: true
- name: "%vx"
summary: Show last or currently evaluated expression in hex
cname: show_value_hex
args:
- name: input
type: RZ_CMD_ARG_TYPE_RZNUM
optional: true
- name: "%vi1"
summary: Show last or currently evaluated expression as 1 byte integer
cname: show_value_i1
args:
- name: input
type: RZ_CMD_ARG_TYPE_RZNUM
optional: true
- name: "%vi2"
summary: Show last or currently evaluated expression as 2 byte integer
cname: show_value_i2
args:
- name: input
type: RZ_CMD_ARG_TYPE_RZNUM
optional: true
- name: "%vi4"
summary: Show last or currently evaluated expression as 4 byte integer
cname: show_value_i4
args:
- name: input
type: RZ_CMD_ARG_TYPE_RZNUM
optional: true
- name: "%vi8"
summary: Show last or currently evaluated expression as 8 byte integer
cname: show_value_i8
args:
- name: input
type: RZ_CMD_ARG_TYPE_RZNUM
optional: true
- name: "%vi"
summary: Show last or currently evaluated expression as integer
cname: show_value_int
args:
- name: input
type: RZ_CMD_ARG_TYPE_RZNUM
optional: true
- name: "%="
summary: Replace the value of last evalued expression with given value
cname: set_core_num_value
args:
- name: input
type: RZ_CMD_ARG_TYPE_RZNUM
- name: "%=="
summary: Compare two given strings and set $? register to cmp result
summary: Compare strings <str1> and <str2> and set $? register to cmp result
cname: compare_and_set_core_num_value
args:
- name: str1
@ -246,7 +233,7 @@ commands:
arg_str: " str1 str2"
comment: $? will be set to 0 if these two strings are equal, otherwise some other positive value.
- name: "%+"
summary: Execute given command if $? register is greater than 0
summary: Execute command <cmd> if $? register is greater than 0
cname: exec_cmd_if_core_num_value_positive
args:
- name: cmd
@ -264,7 +251,7 @@ commands:
arg_str: " %%x"
comment: Won"t do anything
- name: "%-"
summary: Execute given command if $? register is less than 0
summary: Execute command <cmd> if $? register is less than 0
cname: exec_cmd_if_core_num_value_negative
args:
- name: cmd
@ -282,19 +269,19 @@ commands:
arg_str: " %%x"
comment: Won"t do anything
- name: "%!"
summary: Execute command if result of last numeric expression evaluation (related) command was 0
summary: Execute command <cmd> if $? is 0
cname: exec_cmd_if_core_num_value_zero
args:
- name: cmd
type: RZ_CMD_ARG_TYPE_CMD
- name: "%%"
summary: Execute command if result of last numeric expression evaluation (related) command was not 0
summary: Execute command <cmd> if $? is not 0
cname: exec_cmd_if_core_num_value_nonzero
args:
- name: cmd
type: RZ_CMD_ARG_TYPE_CMD
- name: "%l"
summary: Calculate length of string. Quite mode stores value in `$?` register.
summary: Calculate length of string <str>. Quite mode stores value in `$?` register.
cname: calculate_string_length
args:
- name: str
@ -304,7 +291,7 @@ commands:
- RZ_OUTPUT_MODE_STANDARD
- RZ_OUTPUT_MODE_QUIET
- name: "%X"
summary: Show evaluated expression in hex
summary: Show evaluated expression <expr> in hex
cname: calc_expr_show_hex
args:
- name: expr
@ -332,7 +319,7 @@ commands:
- name: hexnum
type: RZ_CMD_ARG_TYPE_RZNUM
- name: "%s"
summary: Generate sequence of numbers (?s from to step)
summary: Generate sequence of numbers from <start> to <stop> with <step> increments
cname: generate_sequence
args:
- name: start
@ -346,14 +333,14 @@ commands:
cname: phys2virt
args:
- name: paddr
type: RZ_CMD_ARG_TYPE_NUM
type: RZ_CMD_ARG_TYPE_RZNUM
optional: true
- name: "%p"
summary: Virtual to physical address conversion
cname: virt2phys
args:
- name: vaddr
type: RZ_CMD_ARG_TYPE_NUM
type: RZ_CMD_ARG_TYPE_RZNUM
optional: true
- name: "%_"
summary: HUD input
@ -366,23 +353,29 @@ commands:
type: RZ_CMD_DESC_TYPE_GROUP
subcommands:
- name: "%i"
summary: Input numerical expression and store in $? register
cname: input_numerical_expr
summary: Input the <prompt> and save response in yank clipboard (`y` commands)
cname: input_prompt
args:
- name: vaddr
type: RZ_CMD_ARG_TYPE_NUM
- name: prompt
type: RZ_CMD_ARG_TYPE_STRING
- name: "%ie"
summary: Input the <prompt>, save response in yank clipboard (`y` commands), and print it
cname: input_prompt_echo
args:
- name: prompt
type: RZ_CMD_ARG_TYPE_STRING
- name: "%in"
summary: Input YES/NO and store result in $? register
summary: Input Yes/No <question> and store result in $? register (default No)
cname: input_yesno_no
args:
- name: opt
- name: question
type: RZ_CMD_ARG_TYPE_STRING
optional: true
- name: "%iy"
summary: Input YES/NO and store result in $? register
summary: Input Yes/No <question> and store result in $? register (default Yes)
cname: input_yesno_yes
args:
- name: opt
- name: question
type: RZ_CMD_ARG_TYPE_STRING
optional: true
- name: "%ik"
@ -390,23 +383,24 @@ commands:
cname: input_any_key
args: []
- name: "%ip"
summary: Yank HUD path and store result in $? register
summary: Interactive HUD mode to find files in <path>
cname: input_yank_hud
args:
- name: path
type: RZ_CMD_ARG_TYPE_STRING
optional: true
- name: "%im"
summary: Input message and display in console
summary: Display <msg> in console and wait for key
cname: input_msg
args:
- name: msg
type: RZ_CMD_ARG_TYPE_STRING
- name: "%if"
summary: Input conditional and store result in $? register
summary: Evaluate <expr>, store result in $? register and print true if <expr> != 0, false otherwise
cname: input_conditional
args:
- name: cond
type: RZ_CMD_ARG_TYPE_STRING
- name: expr
type: RZ_CMD_ARG_TYPE_RZNUM
- name: "%w"
summary: Get references of given address
cname: get_addr_references

View file

@ -221,7 +221,7 @@ RZ_IPI void rz_core_visual_config(RzCore *core) {
" q - quit menu\n"
" j/k - down/up keys\n"
" h/b - go back\n"
" $ - same as ?$ - show values of vars\n"
" $ - same as %%$ - show values of vars\n"
" e/' ' - edit/toggle current variable\n"
" E - edit variable with 'cfg.editor' (vi?)\n"
" +/- - increase/decrease numeric value (* and /, too)\n"

View file

@ -326,10 +326,10 @@ onemoretime:
handleHints(core);
break;
case 'r': // "Vdr"
rz_core_cmdf(core, "?i new function name;afn `yp` @ 0x%08" PFMT64x, off);
rz_core_cmdf(core, "%%i new function name;afn `yp` @ 0x%08" PFMT64x, off);
break;
case 'z': // "Vdz"
rz_core_cmdf(core, "?i zone name;fz `yp` @ 0x%08" PFMT64x, off);
rz_core_cmdf(core, "%%i zone name;fz `yp` @ 0x%08" PFMT64x, off);
break;
case 'R': // "VdR"
eprintf("Finding references to 0x%08" PFMT64x " ...\n", off);

View file

@ -5266,21 +5266,29 @@ bool __handle_console(RzCore *core, RzPanel *panel, const int key) {
switch (key) {
case 'i': {
char cmd[128] = { 0 };
char *prompt = rz_str_newf("[0x%08" PFMT64x "]) ", core->offset);
char *prompt = rz_str_newf("[0x%08" PFMT64x "] ", core->offset);
__panel_prompt(prompt, cmd, sizeof(cmd));
if (*cmd) {
if (!strcmp(cmd, "clear")) {
rz_cons_clear00();
} else {
rz_core_cmdf(core, "?e %s %s>>$console", prompt, cmd);
rz_core_cmdf(core, "%s >>$console", cmd);
char *res = rz_core_cmd_str(core, cmd);
if (!res) {
free(prompt);
return false;
}
char *old_value = rz_cmd_alias_get(core->rcmd, "$console", 1);
char *new_value = rz_str_newf("%s%s %s\n%s\n", old_value ? old_value : "$", prompt, cmd, res);
rz_cmd_alias_set(core->rcmd, "$console", new_value, 1);
free(new_value);
}
}
free(prompt);
panel->view->refresh = true;
}
return true;
}
case 'l':
rz_core_cmd0(core, ":>$console");
rz_cmd_alias_set(core->rcmd, "$console", "", 1);
panel->view->refresh = true;
return true;
default:

View file

@ -57,7 +57,7 @@ static int readline_callback(void *_a, const char *str) {
core->print->cur_enabled = 1;
core->print->ocur = 0;
core->print->cur = (a->acode && a->acode->len) ? a->acode->len - 1 : 0;
char *cmd = rz_str_newf("pd %d @x:%s @0x%" PFMT64x, rows - 11, a->codebuf, a->off);
char *cmd = rz_str_newf("pd %d @x:%s @ 0x%" PFMT64x, rows - 11, a->codebuf, a->off);
char *res = rz_core_cmd_str(a->core, cmd);
char *msg = rz_str_ansi_crop(res, 0, 0, cols - 2, rows - 5);
rz_cons_printf("%s\n", msg);

View file

@ -242,7 +242,7 @@ RZ_IPI int __core_visual_view_graph_update(RzCore *core, RzCoreVisualViewGraph *
rz_cons_strcat_at(mainColstr, colx, 2, colw * 2, colh);
rz_cons_strcat_at(refsColstr, colx * 2, 2, colw, colh);
char *output = rz_core_cmd_strf(core, "pd %d @e:asm.flags=0@ 0x%08" PFMT64x "; pds 256 @ 0x%08" PFMT64x "\n",
char *output = rz_core_cmd_strf(core, "pd %d @e:asm.flags=0 @ 0x%08" PFMT64x "; pds 256 @ 0x%08" PFMT64x "\n",
32, status->addr, status->addr);
int disy = colh + 2;
rz_cons_strcat_at(output, 10, disy, w, h - disy);

View file

@ -109,20 +109,6 @@ typedef struct rz_egg_t {
int context;
} RzEgg;
/* XXX: this may fail in different arches */
#if 0
rizin -q - <<EOF
?e #define RZ_EGG_OS_LINUX \`?h linux\`
?e #define RZ_EGG_OS_OSX \`?h osx\`
?e #define RZ_EGG_OS_DARWIN \`?h darwin\`
?e #define RZ_EGG_OS_MACOS \`?h macos\`
?e #define RZ_EGG_OS_W32 \`?h w32\`
?e #define RZ_EGG_OS_WINDOWS \`?h windows\`
?e #define RZ_EGG_OS_BEOS \`?h beos\`
?e #define RZ_EGG_OS_FREEBSD \`?h freebsd\`
EOF
#endif
#define RZ_EGG_OS_LINUX 0x5ca62a43
#define RZ_EGG_OS_OSX 0x0ad593a1
#define RZ_EGG_OS_DARWIN 0xd86d1ae2

View file

@ -903,7 +903,7 @@ static int rz_type_format_10bytes(const RzTypeDB *typedb, RzStrBuf *outbuf, int
ut8 buffer[255];
int j;
if (MUSTSET) {
rz_strbuf_append(outbuf, "?e pf B not yet implemented\n");
rz_strbuf_append(outbuf, "echo pf B not yet implemented\n");
} else if (mode & RZ_PRINT_DOT) {
for (j = 0; j < 10; j++) {
rz_strbuf_appendf(outbuf, "%02x ", buf[j]);
@ -949,7 +949,7 @@ static int rz_type_format_hexpairs(RzStrBuf *outbuf, int endian, int mode,
int j;
size = (size == -1) ? 1 : size;
if (MUSTSET) {
rz_strbuf_append(outbuf, "?e pf X not yet implemented\n");
rz_strbuf_append(outbuf, "echo pf X not yet implemented\n");
} else if (mode & RZ_PRINT_DOT) {
for (j = 0; j < size; j++) {
rz_strbuf_appendf(outbuf, "%02x", buf[i + j]);

View file

@ -2,7 +2,7 @@
Command substitution used as simple arg $(
=======================================
?e $(p8 10)
echo $(p8 10)
---
@ -17,7 +17,7 @@ Command substitution used as simple arg $(
Command substitution with multiple statements
=======================================
?e $(p8 10; p8 4 @ 0xdeadbeef)
echo $(p8 10; p8 4 @ 0xdeadbeef)
---
@ -38,7 +38,7 @@ Command substitution with multiple statements
Command substitution used as simple arg `
=======================================
?e `p8 10`
echo `p8 10`
---
@ -54,7 +54,7 @@ Command substitution used as simple arg `
Nested command substitution
=======================================
?e $(p8 $(?e 10))
echo $(p8 $(echo 10))
---
@ -71,7 +71,7 @@ Nested command substitution
Nested command substitution 2
=======================================
?e Hello$(?e Wor$(?e ld))
echo Hello$(echo Wor$(echo ld))
---

View file

@ -57,9 +57,9 @@ p8 4 # something
#! identified as comment if not command name
============================================
?e #!this is a comment
?e #this is also a comment
?e # and this too
echo #!this is a comment
echo #this is also a comment
echo # and this too
---

View file

@ -16,7 +16,7 @@ pd 10\@test\>name
Use newlines in echo
====================
?e "Hello\nWorld"
echo "Hello\nWorld"
---
@ -30,7 +30,7 @@ Use newlines in echo
Escape hash
===========
?e Hello\#World
echo Hello\#World
---

View file

@ -28,9 +28,9 @@ afl~$
Grep with cmd substitution as specifier
=======================================
pd 10~`?e mov`
pd 10~mo`?e v`
pd 10~mo$(?e v)
pd 10~`echo mov`
pd 10~mo`echo v`
pd 10~mo$(echo v)
---

View file

@ -66,7 +66,7 @@ p8 @@/x 9090
Iter interpret cmd
==================
p8 @@c:?e hello
p8 @@c:echo hello
---
@ -81,7 +81,7 @@ p8 @@c:?e hello
Iter interpret offsetssizes cmd
===============================
p8 @@@c:?e hello 10
p8 @@@c:echo hello 10
---

View file

@ -2,7 +2,7 @@
Echo with (double) quoted args
==============================
?e "This;is.one@string"
echo "This;is.one@string"
---
@ -14,7 +14,7 @@ Echo with (double) quoted args
Echo with (single) quoted args
==============================
?e 'This;is.one@string'
echo 'This;is.one@string'
---
@ -27,7 +27,7 @@ Echo with (single) quoted args
Legacy command - all quoted
===========================
"?e This;is.one@string"
"echo This;is.one@string"
---
@ -39,7 +39,7 @@ Legacy command - all quoted
Double quoted arg with cmd substitution
=======================================
?e "This is $(?e "a command")"
echo "This is $(echo "a command")"
---
@ -56,9 +56,9 @@ Double quoted arg with cmd substitution
Quoted hash
==================
?e "#"
?e " #$(pdf)"
?e '#'
echo "#"
echo " #$(pdf)"
echo '#'
---

View file

@ -54,6 +54,20 @@ af 0xdeadbeef
(args (arg (arg_identifier)))))
=========================
?v not valid
=========================
?v 3
---
(statements
(help_stmt
(cmd_identifier))
(ERROR))
======================
Percentage mark statements
======================
@ -160,7 +174,7 @@ pf???
(help_stmt (cmd_identifier))
(help_stmt (cmd_identifier))
(help_stmt (cmd_identifier))
(arged_stmt (cmd_identifier))
(help_stmt (cmd_identifier))
(help_stmt (cmd_identifier))
(help_stmt (cmd_identifier))
(help_stmt (cmd_identifier))
@ -173,7 +187,7 @@ pf???
Command with concatenation args
===============================
?e Hello" World"'!' And All
echo Hello" World"'!' And All
---
@ -193,7 +207,7 @@ Command with concatenation args
Tasks command
=============
& ?e Hello
& echo Hello
&& 1
&=
&
@ -215,7 +229,7 @@ Tasks command
Arg with (...)
==============
?e Hello(World)
echo Hello(World)
---
@ -235,7 +249,7 @@ Arg with (...)
Expressions with (...)
============================
?v (100 + (2 - 3)) * 2
%v (100 + (2 - 3)) * 2
---
@ -263,13 +277,13 @@ Expressions with (...)
Arg with $
==========
?v $$
%v $$
s $
?v $*
?v $$$ test
?v $alias
?e hello$alias
?e test
%v $*
%v $$$ test
%v $alias
echo hello$alias
echo test
---

View file

@ -268,7 +268,7 @@ Interpreter statements
Pointer type statements with substitution
=======================================
*entr$(?e y0)=$(?v $$)
*entr$(echo y0)=$(%v $$)
---

View file

@ -60,11 +60,11 @@ static bool is_interpret_cmd(const char *s) {
static bool is_special_start(const int32_t ch) {
return ch == '*' || ch == '(' || ch == '@' || ch == '|' || ch == '>' ||
ch == '.' || ch == '|' || ch == '~' || ch == '!';
ch == '.' || ch == '|' || ch == '~' || ch == '!' || ch == '?';
}
static bool is_start_of_command(const int32_t ch) {
return iswalpha (ch) || ch == '$' || ch == '?' || ch == ':' || ch == '+' ||
return iswalpha (ch) || ch == '$' || ch == ':' || ch == '+' ||
ch == '=' || ch == '/' || ch == '_' || ch == '#' || ch == '\\' ||
ch == '-' || ch == '<' || ch == '&' || ch == '%' || is_special_start (ch);
}
@ -180,10 +180,9 @@ bool tree_sitter_rzcmd_external_scanner_scan(void *payload, TSLexer *lexer, cons
if (is_comment (res)) {
return false;
}
// ?? is not considered an help command, just a regular one
if ((res[i_res - 1] == '?' && strcmp (res, "??") != 0) ||
(i_res > 2 && is_recursive_help (res[i_res - 2], res[i_res - 1])) ||
(i_res > 3 && is_recursive_help_json (res[i_res - 3], res[i_res - 2], res[i_res - 1]))) {
if ((res[i_res - 1] == '?') ||
(i_res >= 2 && is_recursive_help(res[i_res - 2], res[i_res - 1])) ||
(i_res >= 3 && is_recursive_help_json(res[i_res - 3], res[i_res - 2], res[i_res - 1]))) {
if (i_res == 1) {
return false;
}

View file

@ -13,7 +13,7 @@ RUN
NAME=#! with ext != name
FILE==
CMDS=<<EOF
%q `env~?^ASAN_LD_PRELOAD=`
%= `env~?^ASAN_LD_PRELOAD=`
%+ env LD_PRELOAD=`env ASAN_LD_PRELOAD`
echo "#include <stdio.h>\nint main(){printf(\"Hello\\n\");return 0;}" > .tmp-hashextname.c
#!cpipe .tmp-hashextname.c

View file

@ -9,7 +9,7 @@ RUN
NAME=rzpipe.py
FILE=bins/elf/_Exit (42)
CMDS=<<EOF
%q `env~?^ASAN_LD_PRELOAD=`
%= `env~?^ASAN_LD_PRELOAD=`
%+ env LD_PRELOAD=`env ASAN_LD_PRELOAD`
#!pipe python3 scripts/get-funcs.py
EOF
@ -37,7 +37,7 @@ RUN
NAME=rzpipe load project
FILE=--
CMDS=<<EOF
%q `env~?^ASAN_LD_PRELOAD=`
%= `env~?^ASAN_LD_PRELOAD=`
%+ env LD_PRELOAD=`env ASAN_LD_PRELOAD`
!python3 -c 'import rzpipe;rz=rzpipe.open("--");rz.cmd("Po bins/other/ls.rzdb");print(rz.cmd("%v custom_main"))'
EOF
@ -50,7 +50,7 @@ RUN
NAME=rzpipe.py - shared memory (shm://)
FILE=bins/elf/_Exit (42)
CMDS=<<EOF
%q `env~?^ASAN_LD_PRELOAD=`
%= `env~?^ASAN_LD_PRELOAD=`
%+ env LD_PRELOAD=`env ASAN_LD_PRELOAD`
#!pipe python3 scripts/shared_memory.py
EOF

View file

@ -18,7 +18,7 @@ CMDS=<<EOF
# Other stuff is also ignored: `..` ~ ..
# But inside a command line only the commands after the # are ignored.
%v $$ # this must beignored ; ?v $$ | ls
%v $$ # this must beignored ; %v $$ | ls
EOF
EXPECT=<<EOF
0x0

View file

@ -88,7 +88,7 @@ RUN
NAME=rizin shortcut
FILE==
CMDS=<<EOF
%q `!!rizin -h~Usage?`
%= `!!rizin -h~Usage?`
%+ %vi $?
%! echo `!!rizin.bat -h~Usage?`
EOF

View file

@ -5,8 +5,8 @@ BROKEN=1
CMDS=<<EOF
e scr.color=0
db @ entry0
e cmd.bp="?e cmd.bp ran"
dbc "?e bpcmd ran" @ `dbl:start~:2`
e cmd.bp="echo cmd.bp ran"
dbc "echo bpcmd ran" @ `dbl:start~:2`
dc
EOF
EXPECT=<<EOF

View file

@ -5,8 +5,8 @@ BROKEN=1
CMDS=<<EOF
e scr.color=0
db @ entry0
e cmd.bp="?e cmd.bp ran"
dbc "?e bpcmd ran" @ `db~[0]`
e cmd.bp="echo cmd.bp ran"
dbc "echo bpcmd ran" @ `db~[0]`
dc
EOF
EXPECT=<<EOF

View file

@ -3,11 +3,11 @@ FILE=/bin/test
ARGS=-d
BROKEN=1
CMDS=<<EOF
?v $$
%v $$
dcu entry0
ieq
sr PC
?v $$
%v $$
EOF
EXPECT=<<EOF
0x7fff5fc01000

View file

@ -10,7 +10,7 @@ wx 90
pi 1 # hack this shouldnt be here
ds
.dr*
?v rip-a
%v rip-a
EOF
EXPECT=<<EOF
nop
@ -24,7 +24,7 @@ ARGS=-d
BROKEN=1
CMDS=<<EOF
is~?
?!?e zerosyms
?! echo zerosyms
EOF
EXPECT=<<EOF
EOF

View file

@ -1,3 +1,3 @@
Test
{rizin ?e hello world}
{rizin echo hello world}
Eron