{
int nargs = 0;
+#ifdef DEBUG_PARSER
+ printf ("parse_line: \"%s\"\n", line);
+#endif
while (nargs < CFG_MAXARGS) {
/* skip any white space */
if (*line == '\0') { /* end of line, no more args */
argv[nargs] = NULL;
+#ifdef DEBUG_PARSER
+ printf ("parse_line: nargs=%d\n", nargs);
+#endif
return (nargs);
}
if (*line == '\0') { /* end of line, no more args */
argv[nargs] = NULL;
+#ifdef DEBUG_PARSER
+ printf ("parse_line: nargs=%d\n", nargs);
+#endif
return (nargs);
}
printf ("** Too many args (max. %d) **\n", CFG_MAXARGS);
+#ifdef DEBUG_PARSER
+ printf ("parse_line: nargs=%d\n", nargs);
+#endif
return (nargs);
}
#ifdef DEBUG_PARSER
char *output_start = output;
- printf ("[PROCESS_MACROS] INPUT=%s\n", input);
+ printf ("[PROCESS_MACROS] INPUT len %d: \"%s\"\n", strlen(input), input);
#endif
prev = '\0'; /* previous character */
*output = 0;
#ifdef DEBUG_PARSER
- printf ("[PROCESS_MACROS] OUTPUT=%s\n", output_start);
+ printf ("[PROCESS_MACROS] OUTPUT len %d: \"%s\"\n",
+ strlen(output_start), output_start);
#endif
}
int repeatable = 1;
#ifdef DEBUG_PARSER
- printf ("[RUN_COMMAND] cmd=\"%s\"\n", cmd ? cmd : "NULL");
+ printf ("[RUN_COMMAND] cmd[%p]=\"%s\"\n", cmd, cmd ? cmd : "NULL");
#endif
if (!cmd || !*cmd)
return -1; /* empty command, do nothing */
*/
#ifdef DEBUG_PARSER
- printf ("[PROCESS_SEPARATORS] %s\n", s);
+ printf ("[PROCESS_SEPARATORS] %s\n", cmd);
#endif
while (*str) {
const char *sep;
/****************************************************************************/
+/* WARNING:
+ *
+ * We must create a temporary copy of each value we get from
+ * getenv(), since getenv() returns a pointer directly to the
+ * environment data, which may change magicly when the command we run
+ * creates or modifies environment variables (like "bootp" does).
+ */
+
#if (CONFIG_COMMANDS & CFG_CMD_RUN)
void do_run (cmd_tbl_t * cmdtp, bd_t * bd, int flag, int argc, char *argv[])
{
}
for (i=1; i<argc; ++i) {
- run_command (getenv (argv[i]), bd, flag);
+ char arg_buf[CFG_CBSIZE];
+ char *val = getenv (argv[i]);
+ if (val) {
+ strcpy (arg_buf, val);
+ val = arg_buf;
+ }
+ run_command (val, bd, flag);
}
}
#endif