@@ -155,12 +155,9 @@ static RCoreHelpMessage help_msg_l = {
155155
156156static RCoreHelpMessage help_msg_quote = {
157157 "Usage:" , "\"[\"..|..\"]" , "quote the command to avoid evaluating special characters" ,
158- "\"?" , "" , "show this help, NOTE that a single quote is simpler and works the same " ,
158+ "\"?" , "" , "show this help" ,
159159 "\"" , "?e hello \\\"world\\\"\"" , "print (hello \"world\")" ,
160160 "\"" , "?e x;y\";\"?e y;x\"" , "run two commands (prints x;y\ny;x)" ,
161- "\"\"" , "[cmd]" , "directly call a command ignoring all special chars (fast)" ,
162- "\"\"@addr\"\"" , "[cmd]" , "call a command with a temporal seek (EXPERIMENTAL)" ,
163- "\"\"?e x;y\";\"?e y;x" , "" , "run two commands ignoring special chars (prints x;y\";\"?e y;x) " ,
164161 NULL
165162};
166163
@@ -3933,67 +3930,45 @@ static char *find_ch_after_macro(char *ptr, char ch) {
39333930}
39343931
39353932static int handle_command_call (RCore * core , const char * cmd ) {
3936- const char cmd0 = * cmd ;
3937- if (cmd0 != '\'' && cmd0 != '"' ) {
3933+ if (* cmd != '\'' ) {
39383934 return -1 ;
39393935 }
3940- if (R_UNLIKELY (* cmd == '\'' )) {
3941- bool isaddr = cmd [1 ] == '@' ;
3942- if (!strcmp (cmd , "'?" )) {
3943- r_core_cmd_help (core , help_msg_single_quote );
3944- return true;
3945- }
3946- if (isaddr ) {
3947- cmd += 2 ;
3936+ bool isaddr = cmd [1 ] == '@' ;
3937+ if (!strcmp (cmd , "'?" )) {
3938+ r_core_cmd_help (core , help_msg_single_quote );
3939+ return true;
3940+ }
3941+ if (isaddr ) {
3942+ cmd += 2 ;
3943+ } else {
3944+ cmd ++ ;
3945+ }
3946+ if (isaddr || r_str_startswith (cmd , "0x" )) {
3947+ int res = 1 ;
3948+ char * arg = strdup (cmd );
3949+ char * end = strstr (arg , "'" );
3950+ if (end ) {
3951+ * end = 0 ;
3952+ cmd = end + 1 ;
3953+ ut64 addr = core -> addr ;
3954+ ut64 at = r_num_math (core -> num , arg );
3955+ r_core_seek (core , at , true);
3956+ res = r_core_call (core , cmd );
3957+ r_core_seek (core , addr , true);
3958+ free (arg );
39483959 } else {
3949- cmd ++ ;
3950- }
3951- if (isaddr || r_str_startswith (cmd , "0x" )) {
3952- int res = 1 ;
3953- char * arg = strdup (cmd );
3954- char * end = strstr (arg , "'" );
3955- if (end ) {
3956- * end = 0 ;
3957- cmd = end + 1 ;
3958- ut64 addr = core -> addr ;
3959- ut64 at = r_num_math (core -> num , arg );
3960- r_core_seek (core , at , true);
3961- res = r_core_call (core , cmd );
3962- r_core_seek (core , addr , true);
3963- free (arg );
3964- } else {
3965- R_LOG_ERROR ("Invalid syntax, expected \"'@addr'command\"" );
3966- free (arg );
3967- }
3968- return res ;
3960+ R_LOG_ERROR ("Invalid syntax, expected \"'@addr'command\"" );
3961+ free (arg );
39693962 }
3970- return r_core_call ( core , cmd ) ;
3963+ return res ;
39713964 }
3972- if (R_UNLIKELY (r_str_startswith (cmd , "\"\"" ))) {
3973- R_LOG_DEBUG ("The double quote syntax is now deprecated, use the single quote instead" );
3974- // R2_600 - deprecate "" -> use ' <---------- discuss!
3975- if (cmd [2 ] == '@' ) {
3976- int res = 1 ;
3977- char * arg = strdup (cmd + 2 );
3978- char * end = strstr (arg , "\"\"" );
3979- if (!end ) {
3980- R_LOG_ERROR ("Invalid syntax, expected \"\"@addr\"\"command" );
3981- free (arg );
3982- } else {
3983- * end = 0 ;
3984- cmd = end + 2 ;
3985- ut64 addr = core -> addr ;
3986- ut64 at = r_num_math (core -> num , arg + 1 );
3987- r_core_seek (core , at , true);
3988- res = r_core_call (core , cmd );
3989- r_core_seek (core , addr , true);
3990- free (arg );
3991- }
3992- return res ;
3993- }
3994- return r_core_call (core , cmd + 2 );
3965+ return r_core_call (core , cmd );
3966+ }
3967+
3968+ static void remove_leading_empty_quotes (char * cmd ) {
3969+ while (r_str_startswith (cmd , "\"\"" )) {
3970+ memmove (cmd , cmd + 2 , strlen (cmd + 2 ) + 1 );
39953971 }
3996- return -1 ;
39973972}
39983973
39993974static int r_core_cmd_subst (RCore * core , char * cmd ) {
@@ -4009,9 +3984,6 @@ static int r_core_cmd_subst(RCore *core, char *cmd) {
40093984 return res ;
40103985 }
40113986 if (R_UNLIKELY (r_str_startswith (cmd , "?t" ))) {
4012- if (r_str_startswith (cmd + 2 , "\"\"" )) {
4013- return r_core_callf (core , "?t'%s" , cmd + 4 );
4014- }
40153987 if (r_str_startswith (cmd + 2 , "'" )) {
40163988 return r_core_callf (core , "?t'%s" , cmd + 3 );
40173989 }
@@ -4047,6 +4019,7 @@ static int r_core_cmd_subst(RCore *core, char *cmd) {
40474019 }
40484020 cmd = (char * )r_str_trim_head_ro (icmd );
40494021 r_str_trim_tail (cmd );
4022+ remove_leading_empty_quotes (cmd );
40504023 rep = isdigit ((ut8 )* cmd )? strtoull (cmd , NULL , 10 ): 0 ;
40514024 R_CRITICAL_LEAVE (core );
40524025 // lines starting with # are ignored (never reach cmd_hash()), except #! and #?
@@ -4571,6 +4544,7 @@ static int r_core_cmd_subst_i(RCore *core, char *cmd, char *colon, bool *tmpseek
45714544 return 0 ;
45724545 }
45734546 r_str_trim (cmd );
4547+ remove_leading_empty_quotes (cmd );
45744548
45754549 R_CRITICAL_LEAVE (core );
45764550 /* quoted / raw command */
0 commit comments