librz/core: remove old shell completely (#5004)

* Fix UB access of NULL context.

During the tests the global RzCons is accessed. Because it was
never initialized all members were 0.
Leading to undefined behavior and breaking the test with ASAN enabled.

* Use correct yaml example for the command described.

* Remove old shell compatibility code.

* Remove dependency tree of rz_core_cmd_subst() and rz_core_cmd_subst_i().

* Remove rz_core_cmd_pipe_old()

* Remove unused rz_core_hack_help()

* Regenerate grammar after removal of legacy_quoted_stmt.
This commit is contained in:
Rot127 2025-03-17 14:26:22 +00:00 committed by GitHub
parent 2e9a082145
commit 1b50a5b954
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 13490 additions and 16287 deletions

View file

@ -107,18 +107,13 @@ You have to call it according to the `cname` field you previously set for the
Below you can see how the code for adding the `sky` command would look like:
```YAML
- name: s
cname: cmd_seek
summary: Seek to address
type: RZ_CMD_DESC_TYPE_OLDINPUT
subcommands:
- name: sky
cname: sky
summary: Find all occurrences of the work "sky" in the opened file
args:
- name: n
type: RZ_CMD_ARG_TYPE_NUM
optional: true
- name: sky
cname: sky
summary: Print current address / Seek to address
args:
- name: limit
type: RZ_CMD_ARG_TYPE_NUM
optional: true
```
```C
// cmd_seek.c (example, real place depends on the parent command)
@ -145,14 +140,12 @@ If that doesn't work, please report the problem to us! However, you can still
find the handler yourself by looking at the file
[`librz/core/cmd_descs/cmd_descs.yaml`](https://github.com/rizinorg/rizin/blob/6f40dfe493f0caf9e0541e1ee83e3d8012b5750f/librz/core/cmd_descs/cmd_descs.yaml).
By looking at the `cname` field of the command descriptor, you can see what is
the name of the handler of the `x` command. If the `cname` is `hex` and the type
is `RZ_CMD_DESC_TYPE_OLDINPUT`, then the handler will be named `rz_hex`. In all
other cases, the handler will be named `rz_hex_handler`.
the name of the handler of the `x` command. It is always of the form `rz_<cname>_handler`.
So for the command `x` with `cname = hex` the handler is `rz_hex_handler`.
Some examples:
- command: `wv`, type: unspecified (default to `RZ_CMD_DESC_TYPE_ARGV`), handler: `rz_write_value_handler`
- command: `w6d`, type: unspecified (default to `RZ_CMD_DESC_TYPE_ARGV`), handler: `rz_write_base64_decode_handler`
- command: `s`, type: `RZ_CMD_DESC_TYPE_OLDINPUT`, handler: `rz_cmd_seek`
## How to improve the help messages of a command

File diff suppressed because it is too large Load diff

View file

@ -105,7 +105,6 @@ static bool cmd_desc_set_parent(RzCmd *cmd, RzCmdDesc *cd, RzCmdDesc *parent) {
rz_return_val_if_fail(cd && !cd->parent, false);
if (parent) {
switch (parent->type) {
case RZ_CMD_DESC_TYPE_OLDINPUT:
case RZ_CMD_DESC_TYPE_GROUP:
case RZ_CMD_DESC_TYPE_INNER:
break;
@ -346,9 +345,6 @@ static RzCmdDesc *cmd_get_desc_best(RzCmd *cmd, const char *cmd_identifier, bool
}
res = cd;
goto out;
case RZ_CMD_DESC_TYPE_OLDINPUT:
res = cd;
goto out;
case RZ_CMD_DESC_TYPE_INNER:
break;
}
@ -385,10 +381,6 @@ RZ_API RzCmdDesc *rz_cmd_get_desc_best(RzCmd *cmd, const char *cmd_identifier) {
*
* Check if there is a command with exactly the name \p cmd_identifier.
*
* If there isn't, it removes one letter at a time to be compatible with radare2
* behaviour until all commands are converted to rzshell. This best-matching
* works only to find OLDINPUT command references.
*
* \param cmd Reference to RzCmd instance
* \param cmd_identifier Name of the command to search
* \return RzCmdDesc reference or NULL if not found
@ -598,16 +590,6 @@ RZ_API int rz_cmd_call(RzCmd *cmd, const char *input) {
return ret;
}
static RzCmdStatus int2cmdstatus(int v) {
if (v == -2) {
return RZ_CMD_STATUS_EXIT;
} else if (v < 0) {
return RZ_CMD_STATUS_ERROR;
} else {
return RZ_CMD_STATUS_OK;
}
}
static void get_minmax_argc(RzCmdDesc *cd, int *min_argc, int *max_argc) {
*min_argc = 1;
*max_argc = 1;
@ -780,9 +762,6 @@ static RzCmdStatus argv_call_cb(RzCmd *cmd, RzCmdDesc *cd, RzCmdParsedArgs *args
}
static RzCmdStatus call_cd(RzCmd *cmd, RzCmdDesc *cd, RzCmdParsedArgs *args) {
char *exec_string;
RzCmdStatus res = RZ_CMD_STATUS_INVALID;
int i;
const char *s;
rz_cmd_parsed_args_foreach_arg(args, i, s) {
@ -799,11 +778,6 @@ static RzCmdStatus call_cd(RzCmd *cmd, RzCmdDesc *cd, RzCmdParsedArgs *args) {
case RZ_CMD_DESC_TYPE_ARGV_MODES:
case RZ_CMD_DESC_TYPE_ARGV_STATE:
return argv_call_cb(cmd, cd, args);
case RZ_CMD_DESC_TYPE_OLDINPUT:
exec_string = rz_cmd_parsed_args_execstr(args);
res = int2cmdstatus(cd->d.oldinput_data.cb(cmd->core, exec_string + strlen(cd->name)));
RZ_FREE(exec_string);
return res;
default:
RZ_LOG_ERROR("RzCmdDesc type not handled\n");
return RZ_CMD_STATUS_INVALID;
@ -894,7 +868,7 @@ static size_t fill_children_chars(RzStrBuf *sb, const RzCmdDesc *cd) {
}
static bool show_children_shortcut(const RzCmdDesc *cd) {
return cd->n_children || cd->help->options || cd->type == RZ_CMD_DESC_TYPE_OLDINPUT ||
return cd->n_children || cd->help->options ||
has_cd_submodes(cd);
}
@ -1345,28 +1319,6 @@ static char *fake_get_help(RzCmd *cmd, RzCmdDesc *cd, bool use_color) {
return argv_get_help(cmd, cd, 2, use_color);
}
static char *oldinput_get_help(RzCmd *cmd, RzCmdDesc *cd, RzCmdParsedArgs *a) {
if (!cmd->has_cons) {
return NULL;
}
char *res = NULL;
rz_cons_push();
// rz_cons_push disables flushing, which is going to be a problem if a help menu is
// displayed.
rz_cons_set_flush(true);
RzCmdStatus status = rz_cmd_call_parsed_args(cmd, a);
if (status == RZ_CMD_STATUS_OK) {
rz_cons_filter();
res = rz_cons_get_buffer_dup();
}
if (!res) {
res = rz_str_dup("");
}
rz_cons_pop();
return res;
}
static char *get_help(RzCmd *cmd, RzCmdDesc *cd, const char *cmdid, RzCmdParsedArgs *args, bool use_color, size_t detail) {
switch (cd->type) {
case RZ_CMD_DESC_TYPE_GROUP:
@ -1387,8 +1339,6 @@ static char *get_help(RzCmd *cmd, RzCmdDesc *cd, const char *cmdid, RzCmdParsedA
return NULL;
}
return fake_get_help(cmd, cd, use_color);
case RZ_CMD_DESC_TYPE_OLDINPUT:
return oldinput_get_help(cmd, cd, args);
case RZ_CMD_DESC_TYPE_INNER:
rz_warn_if_reached();
return NULL;
@ -1493,7 +1443,6 @@ RZ_API bool rz_cmd_get_help_json(RzCmd *cmd, const RzCmdDesc *cd, PJ *j) {
case (x): \
type = (y); \
break
CASE_CDTYPE(RZ_CMD_DESC_TYPE_OLDINPUT, "oldinput");
CASE_CDTYPE(RZ_CMD_DESC_TYPE_ARGV, "argv");
CASE_CDTYPE(RZ_CMD_DESC_TYPE_GROUP, "group");
CASE_CDTYPE(RZ_CMD_DESC_TYPE_INNER, "inner");
@ -2144,16 +2093,6 @@ RZ_API RzCmdDesc *rz_cmd_desc_group_state_new(RzCmd *cmd, RzCmdDesc *parent, con
return res;
}
RZ_API RzCmdDesc *rz_cmd_desc_oldinput_new(RzCmd *cmd, RzCmdDesc *parent, const char *name, RzCmdCb cb, const RzCmdDescHelp *help) {
rz_return_val_if_fail(cmd && parent && name && cb, NULL);
RzCmdDesc *res = create_cmd_desc(cmd, parent, RZ_CMD_DESC_TYPE_OLDINPUT, name, help, true);
if (!res) {
return NULL;
}
res->d.oldinput_data.cb = cb;
return res;
}
RZ_API RzCmdDesc *rz_cmd_desc_fake_new(RzCmd *cmd, RzCmdDesc *parent, const char *name, const RzCmdDescHelp *help) {
rz_return_val_if_fail(cmd && parent && name && help, NULL);
return create_cmd_desc(cmd, parent, RZ_CMD_DESC_TYPE_FAKE, name, help, true);
@ -2173,8 +2112,6 @@ RZ_API bool rz_cmd_desc_has_handler(const RzCmdDesc *cd) {
return cd->d.argv_modes_data.cb;
case RZ_CMD_DESC_TYPE_ARGV_STATE:
return cd->d.argv_state_data.cb;
case RZ_CMD_DESC_TYPE_OLDINPUT:
return cd->d.oldinput_data.cb;
case RZ_CMD_DESC_TYPE_FAKE:
case RZ_CMD_DESC_TYPE_INNER:
return false;
@ -2276,11 +2213,6 @@ static void cmd_foreach_cmdname(RzCmd *cmd, RzCmdDesc *cd, RzCmdForeachNameCb cb
break;
case RZ_CMD_DESC_TYPE_FAKE:
break;
case RZ_CMD_DESC_TYPE_OLDINPUT:
if (rz_cmd_desc_has_handler(cd)) {
cb(cmd, cd, user);
}
// fallthrough
case RZ_CMD_DESC_TYPE_INNER:
case RZ_CMD_DESC_TYPE_GROUP:
rz_cmd_desc_children_foreach(cd, it_cd) {

View file

@ -10,16 +10,6 @@
#define HIGHLIGHT_SZ 1024
static const char *help_msg_greater_sign[] = {
"Usage:", "[cmd]>[file]", "redirects console from 'cmd' output to 'file'",
"[cmd] > [file]", "", "redirect STDOUT of 'cmd' to 'file'",
"[cmd] > $alias", "", "save the output of the command as an alias (see $?)",
"[cmd] H> [file]", "", "redirect html output of 'cmd' to 'file'",
"[cmd] 2> [file]", "", "redirect STDERR of 'cmd' to 'file'",
"[cmd] 2> /dev/null", "", "omit the STDERR output of 'cmd'",
NULL
};
struct rz_core_var {
const char *name;
const char *description;

View file

@ -13,102 +13,6 @@
#define PF_USAGE_STR "pf[.k[.f[=v]]|[v]]|[n]|[0|cnt][fmt] [a0 a1 ...]"
static const char *help_msg_at[] = {
"Usage: [.][#]<cmd>[*] [`cmd`] [@ addr] [~grep] [|syscmd] [>[>]file]", "", "",
"0", "", "alias for 's 0'",
"0x", "addr", "alias for 's 0x..'",
"#", "cmd", "if # is a number repeat the command # times",
"/*", "", "start multiline comment",
"*/", "", "end multiline comment",
".", "cmd", "execute output of command as rizin script",
".:", "8080", "wait for commands on port 8080",
".!", "rz-bin -re $FILE", "run command output as rizin script",
"*", "", "output of command in rizin script format (CC*)",
"j", "", "output of command in JSON format (pdj)",
"~", "?", "count number of lines (like wc -l)",
"~", "??", "show internal grep help",
"~", "..", "internal less",
"~", "{}", "json indent",
"~", "{}..", "json indent and less",
"~", "word", "grep for lines matching word",
"~", "!word", "grep for lines NOT matching word",
"~", "word[2]", "grep 3rd column of lines matching word",
"~", "word:3[0]", "grep 1st column from the 4th line matching word",
"@", " 0x1024", "temporary seek to this address (sym.main+3)",
"@", " [addr]!blocksize", "temporary set a new blocksize",
"@..", "addr", "temporary partial address seek (see s..)",
"@!", "blocksize", "temporary change the block size (p8@3!3)",
"@{", "from to}", "temporary set from and to for commands supporting ranges",
"@a:", "arch[:bits]", "temporary set arch and bits",
"@b:", "bits", "temporary set asm.bits",
"@B:", "nth", "temporary seek to nth instruction in current bb (negative numbers too)",
"@e:", "k=v,k=v", "temporary change eval vars",
"@f:", "file", "temporary replace block with file contents",
"@F:", "flagspace", "temporary change flag space",
"@i:", "nth.op", "temporary seek to the Nth relative instruction",
"@k:", "k", "temporary seek at value of sdb key `k`",
"@o:", "fd", "temporary switch to another fd",
"@r:", "reg", "tmp seek to reg value (f.ex pd@r:PC)",
"@s:", "string", "same as above but from a string",
"@v:", "value", "modify the current offset to a custom value",
"@x:", "909192", "from hex pairs string",
"@@=", "1 2 3", "run the previous command at offsets 1, 2 and 3",
"@@", " hit*", "run the command on every flag matching 'hit*'",
"@@?", "[ktfb..]", "show help for the iterator operator",
"@@@", " [type]", "run a command on every [type] (see @@@? for help)",
">", "file", "pipe output of command to file",
">>", "file", "append to file",
"H>", "file", "pipe output of command to file in HTML",
"H>>", "file", "append to file with the output of command in HTML",
"`", "pdq~push:0[0]`", "replace output of command inside the line",
"|", "cmd", "pipe output to command (pd|less) (.dr*)",
NULL
};
static const char *help_msg_at_at[] = {
"@@", "", " # foreach iterator command:",
"x", " @@ sym.*", "run 'x' over all flags matching 'sym.' in current flagspace",
"x", " @@dbt[abs]", "run 'x' command on every backtrace address, bp or sp",
"x", " @@.file", "run 'x' over the offsets specified in the file (one offset per line)",
"x", " @@=off1 off2 ..", "manual list of offsets",
"x", " @@/x 9090", "temporary set cmd.hit to run a command on each search result",
"x", " @@k sdbquery", "run 'x' on all offsets returned by that sdbquery",
"x", " @@t", "run 'x' on all threads (see dp)",
"x", " @@b", "run 'x' on all basic blocks of current function (see afb)",
"x", " @@i", "run 'x' on all instructions of the current function (see pdr)",
"x", " @@iS", "run 'x' on all sections adjusting blocksize",
"x", " @@f", "run 'x' on all functions (see aflq)",
"x", " @@f:write", "run 'x' on all functions matching write in the name",
"x", " @@s:from to step", "run 'x' on all offsets from, to incrementing by step",
"x", " @@c:cmd", "the same as @@=`` without the backticks",
"x", " @@=`pdf~call[0]`", "run 'x' at every call offset of the current function",
// TODO: Add @@k sdb-query-expression-here
NULL
};
static const char *help_msg_at_at_at[] = {
"@@@", "", " # foreach offset+size iterator command:",
"x", " @@@=", "[addr] [size] ([addr] [size] ...)",
"x", " @@@b", "basic blocks of current function",
"x", " @@@c:cmd", "Same as @@@=`cmd`, without the backticks",
"x", " @@@C:cmd", "comments matching",
"x", " @@@i", "imports",
"x", " @@@r", "registers",
"x", " @@@s", "symbols",
"x", " @@@st", "strings",
"x", " @@@S", "sections",
"x", " @@@m", "io.maps",
"x", " @@@M", "dbg.maps (See ?$?~size)",
"x", " @@@f", "flags",
"x", " @@@f:hit*", "flags matching glob expression",
"x", " @@@F", "functions (set fcn size which may be incorrect if not linear)",
"x", " @@@F:glob", "functions matching glob expression",
"x", " @@@t", "threads",
"x", " @@@r", "regs",
// TODO: Add @@k sdb-query-expression-here
NULL
};
static const ut32 colormap[256] = {
0x000000,
0x560000,

View file

@ -6,7 +6,6 @@
HANDLER_RULE_OP(statements)
HANDLER_RULE_OP(arged_stmt)
HANDLER_RULE_OP(macro_stmt)
HANDLER_RULE_OP(legacy_quoted_stmt)
HANDLER_RULE_OP(repeat_stmt)
HANDLER_RULE_OP(redirect_stmt)
HANDLER_RULE_OP(help_stmt)

View file

@ -32,8 +32,7 @@
# RzCmdDescArg array
# handler: >
# name of the C handler that handles the command. If not specified it is based
# on the cname. For OLDINPUT, the handler has the form `rz_{cname}`, for all
# other cases it is `rz_{cname}_handler`.
# on the cname.
# subcommands: >
# array of RzCmdDesc/RzCmdDescHelp descriptors. When present the
# type is RZ_CMD_DESC_TYPE_GROUP. Only the first subcommand can contain a

View file

@ -15,7 +15,6 @@ from cmd_descs_util import (
CD_TYPE_FAKE,
CD_TYPE_GROUP,
CD_TYPE_INNER,
CD_TYPE_OLDINPUT,
CD_VALID_TYPES,
compute_cname,
get_handler_cname,
@ -105,9 +104,6 @@ DESC_HELP_TEMPLATE = """static const RzCmdDescHelp {cname} = {{
{description}{args_str}{usage}{options}{details}{details_cb}{args}{sort_subcommands}}};
"""
DEFINE_OLDINPUT_TEMPLATE = """
\tRzCmdDesc *{cname}_cd = rz_cmd_desc_oldinput_new(core->rcmd, {parent_cname}_cd, {name}, {handler_cname}, &{help_cname});
\trz_warn_if_fail({cname}_cd);"""
DEFINE_ARGV_TEMPLATE = """
\tRzCmdDesc *{cname}_cd = rz_cmd_desc_argv_new(core->rcmd, {parent_cname}_cd, {name}, {handler_cname}, &{help_cname});
\trz_warn_if_fail({cname}_cd);"""
@ -438,8 +434,7 @@ class CmdDesc:
sys.exit(1)
if (
self.type
in [CD_TYPE_ARGV, CD_TYPE_ARGV_MODES, CD_TYPE_ARGV_STATE, CD_TYPE_OLDINPUT]
self.type in [CD_TYPE_ARGV, CD_TYPE_ARGV_MODES, CD_TYPE_ARGV_STATE]
and not self.cname
):
print("Command '%s' does not have cname field" % (self.name,))
@ -460,7 +455,6 @@ class CmdDesc:
if self.parent and self.parent.type not in [
CD_TYPE_GROUP,
CD_TYPE_INNER,
CD_TYPE_OLDINPUT,
]:
print("The parent of '%s' is of the wrong type" % (self.cname,))
sys.exit(1)
@ -479,13 +473,12 @@ class CmdDesc:
def get_handler_cname(self):
if self.type not in [
CD_TYPE_OLDINPUT,
CD_TYPE_ARGV,
CD_TYPE_ARGV_MODES,
CD_TYPE_ARGV_STATE,
]:
return None
return get_handler_cname(self.type, self.handler, self.cname)
return get_handler_cname(self.handler, self.cname)
@classmethod
def get_arg_cname(cls, cd):
@ -716,17 +709,6 @@ def createcd(cd):
formatted_string += "\n".join(
[createcd(child) for child in cd.subcommands or []]
)
elif cd.type == CD_TYPE_OLDINPUT:
formatted_string = DEFINE_OLDINPUT_TEMPLATE.format(
cname=cd.cname,
parent_cname=cd.parent.cname,
name=strornull(cd.name),
handler_cname=cd.get_handler_cname(),
help_cname=cd.get_help_cname(),
)
formatted_string += "\n".join(
[createcd(child) for child in cd.subcommands or []]
)
elif cd.type == CD_TYPE_GROUP:
formatted_string = createcd_typegroup(cd)
else:
@ -780,15 +762,6 @@ def handler2decl(cd, cd_type, handler_name, db_names):
)
)
db_names.add(handler_name)
if cd_type == CD_TYPE_OLDINPUT and handler_name not in db_names:
out.append(
'// "%s"\nRZ_IPI int %s(void *data, const char *input);'
% (
cd.name,
handler_name,
)
)
db_names.add(handler_name)
if cd.details_cb is not None and cd.details_cb not in db_names:
out.append(

View file

@ -2,7 +2,6 @@
# SPDX-FileCopyrightText: 2020-2021 ret2libc <sirmy15@gmail.com>
# SPDX-License-Identifier: LGPL-3.0-only
CD_TYPE_OLDINPUT = "RZ_CMD_DESC_TYPE_OLDINPUT"
CD_TYPE_GROUP = "RZ_CMD_DESC_TYPE_GROUP"
CD_TYPE_ARGV = "RZ_CMD_DESC_TYPE_ARGV"
CD_TYPE_ARGV_MODES = "RZ_CMD_DESC_TYPE_ARGV_MODES"
@ -11,7 +10,6 @@ CD_TYPE_FAKE = "RZ_CMD_DESC_TYPE_FAKE"
CD_TYPE_INNER = "RZ_CMD_DESC_TYPE_INNER"
CD_VALID_TYPES = [
CD_TYPE_OLDINPUT,
CD_TYPE_GROUP,
CD_TYPE_ARGV,
CD_TYPE_ARGV_MODES,
@ -61,8 +59,5 @@ def compute_cname(name):
return name
def get_handler_cname(ty, handler, cname):
if ty == CD_TYPE_OLDINPUT:
return "rz_" + (handler or cname)
def get_handler_cname(handler, cname):
return "rz_" + (handler or cname) + "_handler"

View file

@ -10,7 +10,6 @@ import subprocess
import yaml
from cmd_descs_util import (
CD_TYPE_OLDINPUT,
CD_TYPE_FAKE,
CD_TYPE_INNER,
compute_cname,
@ -46,9 +45,6 @@ def get_c_handler_name_from_entry(e):
if "handler" in e and e["handler"]:
name = e["handler"]
if "type" in e and e["type"] == CD_TYPE_OLDINPUT:
return f"rz_{name}"
return f"rz_{name}_handler"
@ -59,9 +55,7 @@ def find_c_name_handler(basedir, rzcommand):
e = find_entry(y["commands"], rzcommand)
if e is not None:
cname = e.get("cname", compute_cname(e["name"]))
return get_handler_cname(
e.get("type", None), e.get("handler", None), cname
)
return get_handler_cname(e.get("handler", None), cname)
return None

View file

@ -8,25 +8,6 @@
* have several modes/alignment requirements.
*/
RZ_API void rz_core_hack_help(const RzCore *core) {
const char *help_msg[] = {
"wao", " [op]", "performs a modification on current opcode",
"wao", " nop", "nop current opcode",
"wao", " jinf", "assemble an infinite loop",
"wao", " jz", "make current opcode conditional (zero)",
"wao", " jnz", "make current opcode conditional (not zero)",
"wao", " ret1", "make the current opcode return 1",
"wao", " ret0", "make the current opcode return 0",
"wao", " retn", "make the current opcode return -1",
"wao", " nocj", "remove conditional operation from branch (make it unconditional)",
"wao", " trap", "make the current opcode a trap",
"wao", " recj", "reverse (swap) conditional branch instruction",
"WIP:", "", "not all archs are supported and not all commands work on all archs",
NULL
};
rz_core_cmd_help(core, help_msg);
}
RZ_API bool rz_core_hack_dalvik(RzCore *core, const char *op, const RzAnalysisOp *aop) {
if (!strcmp(op, "nop")) {
rz_core_write_hexpair(core, core->offset, "0000");

View file

@ -344,17 +344,12 @@ typedef struct rz_cmd_desc_help_t {
} RzCmdDescHelp;
typedef enum rz_cmd_desc_type_t {
/**
* For old handlers that parse their own input and accept a single string.
* Mainly used for legacy reasons with old command handlers.
*/
RZ_CMD_DESC_TYPE_OLDINPUT = 0,
/**
* For handlers that accept argc/argv. It cannot have children. Use
* RZ_CMD_DESC_TYPE_GROUP if you need a command that can be both
* executed and has sub-commands.
*/
RZ_CMD_DESC_TYPE_ARGV,
RZ_CMD_DESC_TYPE_ARGV = 0,
/**
* For cmd descriptors that are parent of other sub-commands, even if
* they may also have a sub-command with the same name. For example,
@ -365,7 +360,7 @@ typedef enum rz_cmd_desc_type_t {
/**
* For cmd descriptors that are just used to group together related
* sub-commands. Do not use this if the command can be used by itself or
* if it's necessary to show its help, because this descriptor is not
* if it's necessary to show its help. Because this descriptor is not
* stored in the hashtable and cannot be retrieved except by listing the
* children of its parent. Most of the time you want RZ_CMD_DESC_TYPE_GROUP.
*/
@ -408,8 +403,8 @@ typedef enum rz_cmd_desc_type_t {
typedef struct rz_cmd_desc_t {
/**
* Type of the command descriptor. There are several types of commands:
* those that are still using the old-style and parses the input string
* themselves, those that accept argc/argv, etc.
* groups, fake and inner have no handlers; argv, mode and state can
* have handlers and get arguments via int argc, char **argv.
*/
RzCmdDescType type;
/**
@ -443,9 +438,6 @@ typedef struct rz_cmd_desc_t {
* Type-specific fields.
*/
union {
struct {
RzCmdCb cb;
} oldinput_data;
struct {
RzCmdArgvCb cb;
int min_argc;
@ -556,7 +548,6 @@ RZ_API RzCmdDesc *rz_cmd_desc_inner_new(RzCmd *cmd, RzCmdDesc *parent, const cha
RZ_API RzCmdDesc *rz_cmd_desc_group_new(RzCmd *cmd, RzCmdDesc *parent, const char *name, RzCmdArgvCb cb, const RzCmdDescHelp *help, const RzCmdDescHelp *group_help);
RZ_API RzCmdDesc *rz_cmd_desc_group_modes_new(RzCmd *cmd, RzCmdDesc *parent, const char *name, int modes, RzCmdArgvModesCb cb, const RzCmdDescHelp *help, const RzCmdDescHelp *group_help);
RZ_API RzCmdDesc *rz_cmd_desc_group_state_new(RzCmd *cmd, RzCmdDesc *parent, const char *name, int modes, RzCmdArgvStateCb cb, const RzCmdDescHelp *help, const RzCmdDescHelp *group_help);
RZ_API RzCmdDesc *rz_cmd_desc_oldinput_new(RzCmd *cmd, RzCmdDesc *parent, const char *name, RzCmdCb cb, const RzCmdDescHelp *help);
RZ_API RzCmdDesc *rz_cmd_desc_fake_new(RzCmd *cmd, RzCmdDesc *parent, const char *name, const RzCmdDescHelp *help);
RZ_API RzCmdDesc *rz_cmd_desc_parent(RzCmdDesc *cd);
RZ_API RzCmdDesc *rz_cmd_desc_get_exec(RzCmdDesc *cd);

View file

@ -452,7 +452,6 @@ RZ_API int rz_core_fgets(char *buf, int len, void *user);
RZ_API RzFlagItem *rz_core_flag_get_by_spaces(RzFlag *f, ut64 off);
RZ_API int rz_core_flush(RzCore *core, const char *cmd);
RZ_API void rz_core_cmd_init(RzCore *core);
RZ_API int rz_core_cmd_pipe_old(RzCore *core, char *rizin_cmd, char *shell_cmd);
RZ_API char *rz_core_cmd_str(RzCore *core, const char *cmd);
RZ_API ut8 *rz_core_cmd_raw(RzCore *core, const char *cmd, int *length);
RZ_API char *rz_core_cmd_strf(RzCore *core, const char *fmt, ...) RZ_PRINTF_CHECK(2, 3);
@ -643,8 +642,6 @@ RZ_API int rz_core_cmd_buffer(RzCore *core, const char *buf);
RZ_API int rz_core_cmdf(RzCore *core, const char *fmt, ...) RZ_PRINTF_CHECK(2, 3);
RZ_API int rz_core_cmd0(RzCore *core, const char *cmd);
RZ_API RzCmdStatus rz_core_cmd0_rzshell(RzCore *core, const char *cmd);
RZ_API int rz_core_cmd_foreach(RzCore *core, const char *cmd, char *each);
RZ_API int rz_core_cmd_foreach3(RzCore *core, const char *cmd, char *each);
RZ_API char *rz_core_op_str(RzCore *core, ut64 addr);
RZ_API RzAnalysisOp *rz_core_op_analysis(RzCore *core, ut64 addr, RzAnalysisOpMask mask);
RZ_API char *rz_core_disassemble_instr(RzCore *core, ut64 addr, int l);
@ -1119,7 +1116,6 @@ RZ_API RZ_OWN RzList /*<RzIOMap *>*/ *rz_core_get_boundaries_debug_stack(RZ_NONN
RZ_API RZ_OWN RzList /*<RzIOMap *>*/ *rz_core_get_boundaries_debug_program(RZ_NONNULL RzCore *core, const RzInterval interval);
RZ_API RZ_OWN RzList /*<RzIOMap *>*/ *rz_core_get_boundaries_select(RZ_NONNULL RzCore *core, RZ_NONNULL const char *from_key, RZ_NONNULL const char *to_key, RZ_NONNULL const char *in_key);
RZ_API void rz_core_hack_help(const RzCore *core);
RZ_API bool rz_core_hack(RzCore *core, const char *op);
RZ_API bool rz_core_dump(RzCore *core, const char *file, ut64 addr, ut64 size, int append);
RZ_API RZ_OWN char *rz_core_clippy(RZ_NONNULL RzCore *core, RZ_NONNULL const char *msg);

View file

@ -23,18 +23,6 @@ echo 'This;is.one@string'
args: (args (arg (single_quoted_arg)))))
===========================
Legacy command - all quoted
===========================
"echo This;is.one@string"
---
(statements
(legacy_quoted_stmt))
=======================================
Double quoted arg with cmd substitution
=======================================

View file

@ -52,8 +52,6 @@ module.exports = grammar({
_statement: ($) => choice($.redirect_stmt, $._simple_stmt),
legacy_quoted_stmt: ($) => seq('"', field("string", token(prec(-1, /([^"\\]|\\(.|\n))+/))), '"'),
_simple_stmt: ($) =>
choice(
$.help_stmt,
@ -64,7 +62,6 @@ module.exports = grammar({
$._iter_stmt,
$._pipe_stmt,
$.grep_stmt,
$.legacy_quoted_stmt,
),
tmp_stmt: ($) => prec.right(seq($._simple_stmt, repeat1($._tmp_op))),

View file

@ -120,34 +120,6 @@
}
]
},
"legacy_quoted_stmt": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "\""
},
{
"type": "FIELD",
"name": "string",
"content": {
"type": "TOKEN",
"content": {
"type": "PREC",
"value": -1,
"content": {
"type": "PATTERN",
"value": "([^\"\\\\]|\\\\(.|\\n))+"
}
}
}
},
{
"type": "STRING",
"value": "\""
}
]
},
"_simple_stmt": {
"type": "CHOICE",
"members": [
@ -182,10 +154,6 @@
{
"type": "SYMBOL",
"name": "grep_stmt"
},
{
"type": "SYMBOL",
"name": "legacy_quoted_stmt"
}
]
},

View file

@ -167,10 +167,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -372,10 +368,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -622,10 +614,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -796,10 +784,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -944,10 +928,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -1092,10 +1072,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -1243,10 +1219,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -1390,10 +1362,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -1537,10 +1505,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -1684,10 +1648,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -1831,10 +1791,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -1982,10 +1938,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -2133,10 +2085,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -2284,10 +2232,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -2431,10 +2375,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -2578,10 +2518,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -2725,10 +2661,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -2872,10 +2804,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -3019,10 +2947,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -3166,10 +3090,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -3317,10 +3237,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -3468,10 +3384,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -3615,10 +3527,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -3762,10 +3670,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -3909,10 +3813,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -4060,10 +3960,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -4207,10 +4103,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -4354,10 +4246,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -4501,10 +4389,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -4524,11 +4408,6 @@
]
}
},
{
"type": "legacy_quoted_stmt",
"named": true,
"fields": {}
},
{
"type": "macro_body",
"named": true,
@ -4653,10 +4532,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -4895,10 +4770,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -5052,10 +4923,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -5232,10 +5099,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -5401,10 +5264,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true
@ -5762,10 +5621,6 @@
"type": "iter_threads_stmt",
"named": true
},
{
"type": "legacy_quoted_stmt",
"named": true
},
{
"type": "macro_stmt",
"named": true

File diff suppressed because it is too large Load diff

View file

@ -16,6 +16,16 @@ static RzCmdDescHelp fake_help = {
.args = fake_args,
};
static RzCmdDescArg fake_args_1[] = {
{ .name = "fake_arg", .type = RZ_CMD_ARG_TYPE_RAW },
{ 0 },
};
static RzCmdDescHelp fake_help_1 = {
.summary = "fake help",
.args = fake_args_1,
};
bool test_parsed_args_noargs(void) {
RzCmdParsedArgs *a = rz_cmd_parsed_args_new("pd", 0, NULL);
mu_assert_streq(a->argv[0], "pd", "pd is the command");
@ -121,23 +131,6 @@ bool test_cmd_descriptor_argv_nested(void) {
mu_end;
}
static int a_oldinput_cb(void *user, const char *input) {
return 0;
}
bool test_cmd_descriptor_oldinput(void) {
RzCmd *cmd = rz_cmd_new(NULL, false);
RzCmdDesc *root = rz_cmd_get_root(cmd);
RzCmdDesc *cd = rz_cmd_desc_oldinput_new(cmd, root, "a", a_oldinput_cb, NULL);
mu_assert_notnull(cd, "cmddesc created");
mu_assert_streq(cd->name, "a", "command descriptor name is a");
mu_assert_eq(cd->type, RZ_CMD_DESC_TYPE_OLDINPUT, "type of command descriptor is oldinput");
mu_assert_ptreq(rz_cmd_desc_parent(cd), root, "root parent descriptor");
mu_assert_eq(cd->n_children, 0, "no children");
rz_cmd_free(cmd);
mu_end;
}
static RzCmdStatus a_exec_cb(RzCore *core, int argc, const char **argv) {
return RZ_CMD_STATUS_OK;
}
@ -192,12 +185,12 @@ static RzCmdStatus aeir_handler(RzCore *core, int argc, const char **argv) {
return RZ_CMD_STATUS_OK;
}
static int ae_handler(void *user, const char *input) {
return 0;
static RzCmdStatus ae_handler(RzCore *core, int argc, const char **argv) {
return RZ_CMD_STATUS_OK;
}
static int w_handler(void *user, const char *input) {
return 0;
static RzCmdStatus w_handler(RzCore *core, int argc, const char **argv) {
return RZ_CMD_STATUS_OK;
}
bool test_cmd_descriptor_tree(void) {
@ -205,7 +198,7 @@ bool test_cmd_descriptor_tree(void) {
RzCmdDesc *root = rz_cmd_get_root(cmd);
RzCmdDesc *a_cd = rz_cmd_desc_group_new(cmd, root, "a", NULL, NULL, &fake_help);
rz_cmd_desc_argv_new(cmd, a_cd, "ap", ap_handler, &fake_help);
rz_cmd_desc_oldinput_new(cmd, root, "w", w_handler, NULL);
rz_cmd_desc_group_new(cmd, root, "w", w_handler, NULL, NULL);
void **it_cd;
rz_cmd_desc_children_foreach(root, it_cd) {
@ -223,9 +216,9 @@ bool test_cmd_get_desc(void) {
RzCmdDesc *a_cd = rz_cmd_desc_group_new(cmd, root, "a", NULL, NULL, &fake_help);
RzCmdDesc *ap_cd = rz_cmd_desc_group_new(cmd, a_cd, "ap", ap_handler, NULL, &fake_help);
RzCmdDesc *apd_cd = rz_cmd_desc_argv_new(cmd, ap_cd, "apd", ap_handler, &fake_help);
RzCmdDesc *ae_cd = rz_cmd_desc_oldinput_new(cmd, a_cd, "ae", ae_handler, NULL);
RzCmdDesc *ae_cd = rz_cmd_desc_argv_new(cmd, a_cd, "ae", ae_handler, NULL);
RzCmdDesc *aeir_cd = rz_cmd_desc_argv_new(cmd, ae_cd, "aeir", aeir_handler, &fake_help);
RzCmdDesc *w_cd = rz_cmd_desc_oldinput_new(cmd, root, "w", w_handler, NULL);
RzCmdDesc *w_cd = rz_cmd_desc_argv_new(cmd, root, "w", w_handler, NULL);
mu_assert_null(rz_cmd_get_desc(cmd, "afl"), "afl does not have any handler");
mu_assert_ptreq(rz_cmd_get_desc(cmd, "ap"), ap_cd, "ap will be handled by ap");
@ -253,25 +246,20 @@ static RzCmdStatus p_handler_argv(RzCore *core, int argc, const char **argv) {
return RZ_CMD_STATUS_OK;
}
static int p_handler(void *user, const char *input) {
mu_assert_streq(input, "x 10", "input is +1");
return -1;
static RzCmdStatus p_handler(RzCore *core, int argc, const char **argv) {
return RZ_CMD_STATUS_ERROR;
}
static int px_handler(void *user, const char *input) {
if (*input == '?') {
rz_cons_printf("Free format px help\n");
}
return 0;
static RzCmdStatus px_handler(RzCore *core, int argc, const char **argv) {
return RZ_CMD_STATUS_OK;
}
static int wv_handler(void *user, const char *input) {
mu_assert_streq(input, "8 0xdeadbeef", "input is +2");
return 1;
static RzCmdStatus wv_handler(RzCore *core, int argc, const char **argv) {
return RZ_CMD_STATUS_OK;
}
static int q_handler(void *user, const char *input) {
return -2;
static RzCmdStatus q_handler(RzCore *core, int argc, const char **argv) {
return RZ_CMD_STATUS_EXIT;
}
bool test_cmd_call_desc(void) {
@ -285,15 +273,15 @@ bool test_cmd_call_desc(void) {
RzCmd *cmd = rz_cmd_new(NULL, false);
RzCmdDesc *root = rz_cmd_get_root(cmd);
RzCmdDesc *p_cd = rz_cmd_desc_group_new(cmd, root, "p", NULL, NULL, &fake_help);
RzCmdDesc *p_cd = rz_cmd_desc_group_new(cmd, root, "p", p_handler, NULL, &fake_help);
RzCmdDesc *w_cd = rz_cmd_desc_group_new(cmd, root, "w", w_handler, NULL, &fake_help);
rz_cmd_desc_argv_new(cmd, p_cd, "pd", pd_handler, &pd_help);
rz_cmd_desc_oldinput_new(cmd, p_cd, "p", p_handler, NULL);
rz_cmd_desc_oldinput_new(cmd, root, "wv", wv_handler, NULL);
rz_cmd_desc_oldinput_new(cmd, root, "q", q_handler, NULL);
mu_assert_notnull(rz_cmd_desc_argv_new(cmd, w_cd, "wv", wv_handler, &fake_help_1), "arg was not added.");
mu_assert_notnull(rz_cmd_desc_argv_new(cmd, root, "q", q_handler, &fake_help), "arg was not added.");
char *pd_args[] = { "10" };
char *px_args[] = { "10" };
char *wv8_args[] = { "0xdeadbeef" };
char *wv_args[] = { "0xdeadbeef" };
RzCmdParsedArgs *a = rz_cmd_parsed_args_new("pd", 1, pd_args);
mu_assert_eq(rz_cmd_call_parsed_args(cmd, a), RZ_CMD_STATUS_OK, "pd was called correctly");
@ -303,11 +291,11 @@ bool test_cmd_call_desc(void) {
mu_assert_eq(rz_cmd_call_parsed_args(cmd, a), RZ_CMD_STATUS_NONEXISTINGCMD, "px was not called because it does not exist");
rz_cmd_parsed_args_free(a);
a = rz_cmd_parsed_args_new("wv8", 1, wv8_args);
a = rz_cmd_parsed_args_new("wv", 1, wv_args);
mu_assert_eq(rz_cmd_call_parsed_args(cmd, a), RZ_CMD_STATUS_OK, "wv was called correctly");
rz_cmd_parsed_args_free(a);
a = rz_cmd_parsed_args_new("quit", 0, NULL);
a = rz_cmd_parsed_args_new("q", 0, NULL);
mu_assert_eq(rz_cmd_call_parsed_args(cmd, a), RZ_CMD_STATUS_EXIT, "quit is going to exit");
rz_cmd_parsed_args_free(a);
@ -356,11 +344,11 @@ bool test_cmd_help(void) {
RzCmdDesc *root = rz_cmd_get_root(cmd);
RzCmdDesc *p_cd = rz_cmd_desc_group_new(cmd, root, "p", NULL, NULL, &p_group_help);
rz_cmd_desc_argv_new(cmd, p_cd, "pd", pd_handler, &pd_help);
rz_cmd_desc_oldinput_new(cmd, p_cd, "px", px_handler, &px_help);
rz_cmd_desc_argv_new(cmd, p_cd, "px", px_handler, &px_help);
const char *p_help_exp = "Usage: p-usage # p summary\n"
"| pd <num> # pd summary\n"
"| px[?] <verylongarg_str_num> # px summary\n";
"| pd <num> # pd summary\n"
"| px <verylongarg_str_num> # px summary\n";
RzCmdParsedArgs *a = rz_cmd_parsed_args_newcmd("p?");
char *h = rz_cmd_get_help(cmd, a, false);
mu_assert_notnull(h, "help is not null");
@ -437,28 +425,6 @@ bool test_cmd_group_help(void) {
mu_end;
}
bool test_cmd_oldinput_help(void) {
rz_cons_new();
RzCmd *cmd = rz_cmd_new(NULL, true);
RzCmdDesc *root = rz_cmd_get_root(cmd);
RzCmdDesc *p_cd = rz_cmd_desc_group_new(cmd, root, "p", NULL, NULL, &fake_help);
rz_cmd_desc_argv_new(cmd, p_cd, "pd", pd_handler, &fake_help);
rz_cmd_desc_oldinput_new(cmd, p_cd, "px", px_handler, NULL);
RzCmdParsedArgs *a = rz_cmd_parsed_args_newcmd("px?");
const char *px_help_exp = "Free format px help\n";
char *h = rz_cmd_get_help(cmd, a, false);
mu_assert_notnull(h, "help is not null");
mu_assert_streq(h, px_help_exp, "wrong help for px?");
free(h);
rz_cmd_parsed_args_free(a);
rz_cmd_free(cmd);
rz_cons_free();
mu_end;
}
bool test_cmd_group_exec_help(void) {
const RzCmdDescHelp p_help = {
.summary = "p summary",
@ -741,10 +707,9 @@ bool test_foreach_cmdname(void) {
rz_cmd_desc_fake_new(cmd, root, "x", &fake_help);
RzCmdDesc *p_cd = rz_cmd_desc_group_new(cmd, root, "p", NULL, NULL, &fake_help);
rz_cmd_desc_argv_new(cmd, p_cd, "pi", zd_handler, &fake_help);
RzCmdDesc *v_cd = rz_cmd_desc_oldinput_new(cmd, root, "v", a_oldinput_cb, &fake_help);
RzCmdDesc *v_inner_cd = rz_cmd_desc_inner_new(cmd, v_cd, "v", &fake_help);
rz_cmd_desc_argv_new(cmd, v_inner_cd, "v1", zd_handler, &fake_help);
rz_cmd_desc_argv_new(cmd, v_inner_cd, "v2", zd_handler, &fake_help);
RzCmdDesc *v_cd = rz_cmd_desc_group_new(cmd, root, "v", zd_handler, &fake_help, &fake_help);
rz_cmd_desc_argv_new(cmd, v_cd, "v1", zd_handler, &fake_help);
rz_cmd_desc_argv_new(cmd, v_cd, "v2", zd_handler, &fake_help);
RzList *res = rz_list_newf(free);
rz_cmd_foreach_cmdname(cmd, NULL, foreach_cmdname_cb, res);
@ -782,10 +747,9 @@ bool test_foreach_cmdname_begin(void) {
rz_cmd_desc_fake_new(cmd, root, "x", &fake_help);
RzCmdDesc *p_cd = rz_cmd_desc_group_new(cmd, root, "p", NULL, NULL, &fake_help);
rz_cmd_desc_argv_new(cmd, p_cd, "pi", zd_handler, &fake_help);
RzCmdDesc *v_cd = rz_cmd_desc_oldinput_new(cmd, root, "v", a_oldinput_cb, &fake_help);
RzCmdDesc *v_inner_cd = rz_cmd_desc_inner_new(cmd, v_cd, "v", &fake_help);
rz_cmd_desc_argv_new(cmd, v_inner_cd, "v1", zd_handler, &fake_help);
rz_cmd_desc_argv_new(cmd, v_inner_cd, "v2", zd_handler, &fake_help);
RzCmdDesc *v_cd = rz_cmd_desc_group_new(cmd, root, "v", zd_handler, &fake_help, &fake_help);
rz_cmd_desc_argv_new(cmd, v_cd, "v1", zd_handler, &fake_help);
rz_cmd_desc_argv_new(cmd, v_cd, "v2", zd_handler, &fake_help);
RzList *res = rz_list_newf(free);
rz_cmd_foreach_cmdname(cmd, v_cd, foreach_cmdname_cb, res);
@ -1328,9 +1292,9 @@ bool test_get_best_match(void) {
RzCmdDesc *a_cd = rz_cmd_desc_group_new(cmd, root, "a", NULL, NULL, &fake_help);
RzCmdDesc *ap_cd = rz_cmd_desc_group_new(cmd, a_cd, "ap", ap_handler, NULL, &fake_help);
RzCmdDesc *apd_cd = rz_cmd_desc_argv_new(cmd, ap_cd, "apd", ap_handler, &fake_help);
RzCmdDesc *ae_cd = rz_cmd_desc_oldinput_new(cmd, a_cd, "ae", ae_handler, NULL);
RzCmdDesc *ae_cd = rz_cmd_desc_argv_new(cmd, a_cd, "ae", ae_handler, NULL);
rz_cmd_desc_argv_new(cmd, ae_cd, "aeir", aeir_handler, &fake_help);
rz_cmd_desc_oldinput_new(cmd, root, "w", w_handler, NULL);
rz_cmd_desc_argv_new(cmd, root, "w", w_handler, NULL);
mu_assert_ptreq(rz_cmd_get_desc_best(cmd, "ap"), ap_cd, "ap should be best match for ap");
mu_assert_ptreq(rz_cmd_get_desc_best(cmd, "apn"), ap_cd, "ap should be best match for apn");
@ -1467,6 +1431,7 @@ bool test_call_multiple_macros(void) {
}
int all_tests() {
rz_cons_new();
mu_run_test(test_parsed_args_noargs);
mu_run_test(test_parsed_args_onearg);
mu_run_test(test_parsed_args_args);
@ -1475,14 +1440,12 @@ int all_tests() {
mu_run_test(test_parsed_args_newargs);
mu_run_test(test_cmd_descriptor_argv);
mu_run_test(test_cmd_descriptor_argv_nested);
mu_run_test(test_cmd_descriptor_oldinput);
mu_run_test(test_cmd_descriptor_tree);
mu_run_test(test_cmd_descriptor_group);
mu_run_test(test_cmd_get_desc);
mu_run_test(test_cmd_call_desc);
mu_run_test(test_cmd_help);
mu_run_test(test_cmd_group_help);
mu_run_test(test_cmd_oldinput_help);
mu_run_test(test_cmd_group_exec_help);
mu_run_test(test_remove_cmd);
mu_run_test(test_cmd_args);