Add -e cmd.exit to run commands before leaving ##shell

This commit is contained in:
pancake 2024-09-30 10:09:49 +02:00 committed by pancake
parent e295df766a
commit a0f69577f5
2 changed files with 5 additions and 0 deletions

View File

@ -4021,6 +4021,7 @@ R_API int r_core_config_init(RCore *core) {
SETPREF ("cmd.usr2", "", "run when SIGUSR2 signal is received");
#endif
SETPREF ("cmd.open", "", "run when file is opened");
SETPREF ("cmd.exit", "", "run command before leaving the shell (atexit)");
SETPREF ("cmd.load", "", "run when binary is loaded");
SETPREF ("cmd.bbgraph", "", "show the output of this command in the graph basic blocks");
RConfigNode *cmdpdc = NODECB ("cmd.pdc", "", &cb_cmdpdc);

View File

@ -1883,6 +1883,10 @@ R_API int r_main_radare2(int argc, const char **argv) {
}
}
const char *cmd_exit = r_config_get (r->config, "cmd.exit");
if (R_STR_ISNOTEMPTY (cmd_exit)) {
r_core_cmd0 (r, cmd_exit);
}
const char *prj = r_config_get (r->config, "prj.name");
if (R_STR_ISNOTEMPTY (prj)) {
if (r_core_project_is_dirty (r) && !r_config_get_b (r->config, "prj.alwaysprompt")) {