Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Honor numeric argument in q!! and simplify command logic ##shell #23081

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions libr/core/cmd_quit.inc.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* radare - LGPL - Copyright 2009-2023 - pancake */
/* radare - LGPL - Copyright 2009-2024 - pancake */

#if R_INCLUDE_BEGIN

Expand All @@ -17,21 +17,25 @@ static RCoreHelpMessage help_msg_q = {

static int cmd_Quit(void *data, const char *input) {
RCore *core = (RCore *)data;
if (input[0] == '!') {
if (input[1] == '!' || !input[1]) {
const char *arg = strchr (input, ' ');
if (!arg) {
while (*input == '!') {
input++;
}
arg = input;
}
const int rv = arg? r_num_math (core->num, arg): 0;
if (input[0] == '!') { // "q!"
if (input[1] == '!' || !input[1]) { // "q!!"
if (!r_sandbox_enable (false)) {
r_cons_flush ();
exit (0);
exit (rv);
}
return R_CMD_RC_QUIT;
}
r_config_set_b (core->config, "scr.hist.save", false);
}
if (IS_DIGIT (input[0]) || input[0] == ' ') {
r_core_return_code (core, r_num_math (core->num, input));
} else {
r_core_return_code (core, 0);
}
r_core_return_code (core, rv);
return R_CMD_RC_QUIT;
}

Expand Down
Loading