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

Fix #4816: Apply @ temp operators from left to right #4826

Merged
merged 4 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
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
180 changes: 104 additions & 76 deletions librz/core/cmd/cmd.c

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions librz/core/cmd/rz-shell-parser-cmds.inc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ HANDLER_RULE_OP(legacy_quoted_stmt)
HANDLER_RULE_OP(repeat_stmt)
HANDLER_RULE_OP(redirect_stmt)
HANDLER_RULE_OP(help_stmt)
HANDLER_RULE_OP(tmp_stmt)
HANDLER_RULE_OP(tmp_seek_stmt)
HANDLER_RULE_OP(tmp_blksz_stmt)
HANDLER_RULE_OP(tmp_fromto_stmt)
Expand Down
2 changes: 1 addition & 1 deletion librz/core/cmd_descs/cmd_descs.c
Original file line number Diff line number Diff line change
Expand Up @@ -19070,7 +19070,7 @@ static const RzCmdDescDetail tmp_modifiers_details[] = {
{ 0 },
};
static const RzCmdDescHelp tmp_modifiers_help = {
.summary = "'@' help, temporary modifiers, applied right-to-left",
.summary = "'@' help, temporary modifiers, applied left-to-right",
.usage = "<cmd> <@> <args> [<@> <args> ...]",
.options = "[?]",
.details = tmp_modifiers_details,
Expand Down
2 changes: 1 addition & 1 deletion librz/core/cmd_descs/cmd_descs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ commands:
- name: "@"
cname: tmp_modifiers
options: "[?]"
summary: "'@' help, temporary modifiers, applied right-to-left"
summary: "'@' help, temporary modifiers, applied left-to-right"
type: RZ_CMD_DESC_TYPE_FAKE
usage: "<cmd> <@> <args> [<@> <args> ...]"
details:
Expand Down
107 changes: 71 additions & 36 deletions subprojects/rizin-shell-parser/corpus/cmd_substitution.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@ echo $(p8 10)
---

(statements
(arged_stmt command: (cmd_identifier)
(arged_stmt
command: (cmd_identifier)
args: (args
(arg (cmd_substitution_arg
(arged_stmt command: (cmd_identifier)
args: (args (arg (arg_identifier)))))))))
(arg
(cmd_substitution_arg
(arged_stmt
command: (cmd_identifier)
args: (args
(arg
(arg_identifier)))))))))

=======================================
Command substitution with multiple statements
Expand All @@ -22,17 +27,26 @@ echo $(p8 10; p8 4 @ 0xdeadbeef)
---

(statements
(arged_stmt command: (cmd_identifier)
(arged_stmt
command: (cmd_identifier)
args: (args
(arg (cmd_substitution_arg
(arged_stmt command: (cmd_identifier)
args: (args (arg (arg_identifier))))
(tmp_seek_stmt
(arged_stmt command: (cmd_identifier)
args: (args (arg (arg_identifier))))
(args (arg (arg_identifier)))))))))


(arg
(cmd_substitution_arg
(arged_stmt
command: (cmd_identifier)
args: (args
(arg
(arg_identifier))))
(tmp_stmt
(arged_stmt
command: (cmd_identifier)
args: (args
(arg
(arg_identifier))))
(tmp_seek_stmt
(args
(arg
(arg_identifier))))))))))

=======================================
Command substitution used as simple arg `
Expand All @@ -43,12 +57,16 @@ echo `p8 10`
---

(statements
(arged_stmt command: (cmd_identifier)
(arged_stmt
command: (cmd_identifier)
args: (args
(arg (cmd_substitution_arg
(arged_stmt command: (cmd_identifier)
args: (args (arg (arg_identifier)))))))))

(arg
(cmd_substitution_arg
(arged_stmt
command: (cmd_identifier)
args: (args
(arg
(arg_identifier)))))))))

=======================================
Nested command substitution
Expand All @@ -59,13 +77,21 @@ echo $(p8 $(echo 10))
---

(statements
(arged_stmt command: (cmd_identifier)
args: (args (arg (cmd_substitution_arg
(arged_stmt command: (cmd_identifier)
args: (args (arg (cmd_substitution_arg
(arged_stmt command: (cmd_identifier)
args: (args (arg (arg_identifier)))))))))))))

(arged_stmt
command: (cmd_identifier)
args: (args
(arg
(cmd_substitution_arg
(arged_stmt
command: (cmd_identifier)
args: (args
(arg
(cmd_substitution_arg
(arged_stmt
command: (cmd_identifier)
args: (args
(arg
(arg_identifier)))))))))))))

=======================================
Nested command substitution 2
Expand All @@ -76,13 +102,22 @@ echo Hello$(echo Wor$(echo ld))
---

(statements
(arged_stmt (cmd_identifier)
(args (arg (concatenation
(arg_identifier)
(cmd_substitution_arg
(arged_stmt (cmd_identifier)
(args (arg (concatenation
(arg_identifier)
(cmd_substitution_arg
(arged_stmt (cmd_identifier)
(args (arg (arg_identifier)))))))))))))))
(arged_stmt
(cmd_identifier)
(args
(arg
(concatenation
(arg_identifier)
(cmd_substitution_arg
(arged_stmt
(cmd_identifier)
(args
(arg
(concatenation
(arg_identifier)
(cmd_substitution_arg
(arged_stmt
(cmd_identifier)
(args
(arg
(arg_identifier)))))))))))))))
41 changes: 27 additions & 14 deletions subprojects/rizin-shell-parser/corpus/repeated_commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ One digit repeat statements
(statements
(repeat_stmt
(number)
(arged_stmt (cmd_identifier)
(args (arg (arg_identifier))))))

(arged_stmt
(cmd_identifier)
(args
(arg
(arg_identifier))))))

=========================
Multiple digits repeat statements
Expand All @@ -24,9 +26,11 @@ Multiple digits repeat statements
(statements
(repeat_stmt
(number)
(arged_stmt (cmd_identifier)
(args (arg (arg_identifier))))))

(arged_stmt
(cmd_identifier)
(args
(arg
(arg_identifier))))))

=======================
Repeat with redirection
Expand All @@ -40,11 +44,14 @@ Repeat with redirection
(redirect_stmt
(repeat_stmt
(number)
(arged_stmt (cmd_identifier)
(args (arg (arg_identifier)))))
(arged_stmt
(cmd_identifier)
(args
(arg
(arg_identifier)))))
(fdn_redirect_operator)
(arg (arg_identifier))))

(arg
(arg_identifier))))

====================
Repeat with tmp seek
Expand All @@ -55,9 +62,15 @@ Repeat with tmp seek
---

(statements
(tmp_seek_stmt
(tmp_stmt
(repeat_stmt
(number)
(arged_stmt (cmd_identifier)
(args (arg (arg_identifier)))))
(args (arg (arg_identifier)))))
(arged_stmt
(cmd_identifier)
(args
(arg
(arg_identifier)))))
(tmp_seek_stmt
(args
(arg
(arg_identifier))))))
Loading
Loading