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

radare2-shell-parser: command substitution #15886

Open
ret2libc opened this issue Jan 23, 2020 · 2 comments
Open

radare2-shell-parser: command substitution #15886

ret2libc opened this issue Jan 23, 2020 · 2 comments

Comments

@ret2libc
Copy link
Collaborator

@ret2libc ret2libc commented Jan 23, 2020

A feature that still makes me think a lot is how we want to handle command substitution. I would like to have some feedback and thoughts about it, so that I can implement it in radare2-shell-parser, as the way we implement it will change a lot how the parser works.

  1. Commands substitutions can appear anywhere, they are just string-replaced.
    Example: p$(?e "d 10~xor") becomes => pd 10~xor
  2. Commands substitutions can only be in arguments and they can generate new arguments
    Example: o $(?e "myfile 0x4000 rwx") is interpreted as o myfile 0x4000 rwx.
  3. Commands substitutions can only be in arguments and they can't generate new arguments
    Example: o $(?e "myfile 0x4000 rwx") is interpreted as o "myfile 0x4000 rwx" (which would not work because o expects 3 arguments.
  4. Commands substitutions can only be in arguments and they can generate new tokens or new commands as well.
    Example: f $(?e "ciao @ 0xdeadbeef; f-") ciao is interpreted as f ciao @ 0xdeadbeef; f- ciao

Other ideas? Suggestions? What do you think is the clearest/best thing? Bash seems to use a sort of 1/2.

@ret2libc

This comment has been minimized.

Copy link
Collaborator Author

@ret2libc ret2libc commented Jan 24, 2020

I'm going to try 2.

The reason I don't like 3 is because I think it makes sense for a cmd_substitution to generate more than one argument token.
The reason I don't like 4 is because if you allow the cmd_substitution to generate any kind of new token, you can hardly parse the input because until you execute each substitution you don't know the structure of the final input.

@XVilka

This comment has been minimized.

Copy link
Member

@XVilka XVilka commented Jan 24, 2020

I think restricting them to just arguments->arguments substitution is good enough. I don't remember any case when I needed something more advanced (and if you need something more advanced - just use macroses or r2pipe).

@XVilka XVilka added this to To do in Console Interface Improvements via automation Jan 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.