main: unify command parsing functions
PATCH v2 1/1 main: unify command parsing functions
Introduce source_commands() which incorporates run_command2() and parts of source().
All command script are now treated the same, that is newlines are accepted within a command script and variable.
---
This patch supersedes "cmd_source: introduce run_script()" v2:
- argument is now const char*
- unify run_commands2() and source()
- allow newlines in command variables
- use strsep()
common/cmd_pxe.c | 2 +- common/cmd_source.c | 32 +------------------------------ common/main.c | 52 ++++++++++++++++++++++++++++++++++---------------- include/common.h | 4 +-- 4 files changed, 38 insertions(+), 52 deletions(-)
common/cmd_pxe.c +1 -1
@@ -537,7 +537,7 @@ static int label_localboot(struct pxe_label *label)printf ("running: %s\n" , dupcmd); - ret =run_command2 (dupcmd,0 ); + ret =source_commands (dupcmd,0 );free (dupcmd);
common/cmd_source.c +1 -31
@@ -160,38 +160,8 @@ source (ulong addr, const char *fit_uname)memmove (cmd, (char *)data, len); *(cmd + len) =0 ; -#ifdef CONFIG_SYS_HUSH_PARSER /*?? */ - rcode =parse_string_outer (cmd,FLAG_PARSE_SEMICOLON ); -#else - { -char *line = cmd; -char *next = cmd; + rcode =source_commands (cmd,0 ); -/* -* break into individual lines, -* and execute each line; -* terminate on error. -*/ -while (*next) { -if (*next =='\n' ) { - *next ='\0' ; -/* run only non-empty commands */ -if (*line) { -debug ("** exec: \"%s\"\n" , - line); -if (run_command (line,0 ) <0 ) { - rcode =1 ; -break ; - } - } - line = next +1 ; - } - ++next; - } -if (rcode ==0 && *line) - rcode = (run_command (line,0 ) >=0 ); - } -#endif free (cmd);return rcode; }
common/main.c +35 -17
89 lines not on this page · raw message
include/common.h +1 -3
@@ -261,9 +261,7 @@ int print_buffer (ulong addr, void* data, uint width, uint count, uint linelen);/* common/main.c */ void main_loop (void );int run_command (const char *cmd,int flag); -#ifdef CONFIG_CMD_PXE -int run_command2 (const char *cmd,int flag); -#endif +int source_commands (const char *cmd,int flag);int readline (const char *const prompt);int readline_into_buffer (const char *const prompt,char * buffer);int parse_line (char *,char *[]);
Signature · 1 line
1.7.2.5
PATCH v2 1/1 main: unify command parsing functions
Dear Michael Walle,
Quoted 5 lines · In message <[email protected]> you wrote:
Introduce
source_commands()which incorporatesrun_command2()and parts ofsource().All command script are now treated the same, that is newlines are accepted within a command script and variable.
Please check if this is still needed after applying Simon Glass' "Unified command execution in one place" series (and if so, please rebase against current master).
Thanks.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Very ugly or very beautiful women should be flattered on their
understanding, and mediocre ones on their beauty.
-- Philip Earl of ChesterfieldPATCH v2 1/1 main: unify command parsing functions
Hi Wolfgang,
Am Dienstag 06 M?rz 2012, 21:39:16 schrieb Wolfgang Denk:
Quoted 10 lines
Quoted 5 lines · In message <[email protected]> you wrote:
Introduce
source_commands()which incorporatesrun_command2()and parts ofsource().All command script are now treated the same, that is newlines are accepted within a command script and variable.
Please check if this is still needed after applying Simon Glass' "Unified command execution in one place" series (and if so, please rebase against current master).
This patches is superseded by
[PATCH 1/2] Add run_command_list() to run a list of commands [PATCH 2/2] Allow newlines within command environment vars
by Simon Glass.
These patches haven't been merged yet.
Signature · 1 line
michael
PATCH v2 1/1 main: unify command parsing functions
Hi,
Quoted 14 lines · Michael Walle
Hi Wolfgang,
Am Dienstag 06 M?rz 2012, 21:39:16 schrieb Wolfgang Denk:
Quoted 10 lines
Quoted 5 lines · In message <[email protected]> you wrote:
Introduce
source_commands()which incorporatesrun_command2()and parts ofsource().All command script are now treated the same, that is newlines are accepted within a command script and variable.
Please check if this is still needed after applying Simon Glass' "Unified command execution in one place" series (and if so, please rebase against current master).
Quoted 7 lines
This patches is superseded by
?[PATCH 1/2] Addrun_command_list()to run a list of commands ?[PATCH 2/2] Allow newlines within command environment vars by Simon Glass.These patches haven't been merged yet.
Yes - in fact these should go into 'next' I think. But first I need to respond to Wolfgang's email on that series.
Regards,
Simon
Quoted 2 lines
--
michael
PATCH v2 1/1 main: unify command parsing functions
Dear Simon Glass,
Quoted 5 lines · In message <CAPnjgZ1JwBM=GSR87jU79zZzm0Xv2QCQbh5=VoFRh-1B5y1jLQ@mail.gmail.com>…
Quoted 2 lines
These patches haven't been merged yet.
Yes - in fact these should go into 'next' I think. But first I need to respond to Wolfgang's email on that series.
See previous mail.
Actually I'd like to pullthes epatches in for this release. I consider especially the multi-line command handling a bug fix.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Der Horizont vieler Menschen ist ein Kreis mit Radius Null -- und das nennen sie ihren Standpunkt.
PATCH v2 1/1 main: unify command parsing functions
Hi Wolfgang,
Quoted 6 lines · Wolfgang Denk
Dear Simon Glass,
Quoted 3 lines · In message <CAPnjgZ1JwBM=GSR87jU79zZzm0Xv2QCQbh5=VoFRh-1B5y1jLQ@mail.gmail.com>…
Quoted 2 lines
These patches haven't been merged yet.
Quoted 7 lines
Quoted 2 lines
Yes - in fact these should go into 'next' I think. But first I need to respond to Wolfgang's email on that series.
See previous mail.
Actually I'd like to pullthes epatches in for this release. ?I consider especially the multi-line command handling a bug fix.
OK, let me have another look at it.
Regards,
Simon
Quoted 11 lines
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, ? ? MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Der Horizont vieler Menschen ist ein Kreis mit Radius Null -- und das nennen sie ihren Standpunkt.
PATCH v2 1/1 main: unify command parsing functions
In reply to Wolfgang DenkHi Wolfgang,
Quoted 6 lines · Wolfgang Denk
Dear Simon Glass,
Quoted 3 lines · In message <CAPnjgZ1JwBM=GSR87jU79zZzm0Xv2QCQbh5=VoFRh-1B5y1jLQ@mail.gmail.com>…
Quoted 2 lines
These patches haven't been merged yet.
Quoted 7 lines
Quoted 2 lines
Yes - in fact these should go into 'next' I think. But first I need to respond to Wolfgang's email on that series.
See previous mail.
Actually I'd like to pullthes epatches in for this release. ?I consider especially the multi-line command handling a bug fix.
Sorry I didn't get to this earlier. I decided it needed a bit more work.
I am going to send the 2 patches updated, plus a sandbox compile error fix that we now need, and a unit test (just as a proposal). See what you think.
Regards,
Simon
Quoted 11 lines
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, ? ? MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Der Horizont vieler Menschen ist ein Kreis mit Radius Null -- und das nennen sie ihren Standpunkt.
PATCH v2 1/1 main: unify command parsing functions
In reply to Michael WalleDear Michael Walle,
Quoted 7 lines · In message <[email protected]> you wrote:
This patches is superseded by
[PATCH 1/2] Addrun_command_list()to run a list of commands [PATCH 2/2] Allow newlines within command environment vars
by Simon Glass.These patches haven't been merged yet.
Thanks for the explanation.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"He only drinks when he gets depressed." "Why does he get depressed?"
"Sometimes it's because he hasn't had a drink."
- Terry Pratchett, _Men at Arms_