(CONFIG_COMMANDS & CFG_CMD_AUTOSCRIPT)
#ifdef CFG_HUSH_PARSER
-extern int parse_string_outer(char *s);
+extern int parse_string_outer(char *s, int end);
#endif
extern image_header_t header; /* from cmd_bootm.c */
#ifndef CFG_HUSH_PARSER
rcode = run_command(cmd, bd, 0);
#else
- rcode = parse_string_outer(cmd);
+ rcode = parse_string_outer(cmd, 1);
#endif
free(cmd);
return rcode;
#endif
#ifdef CFG_HUSH_PARSER
-extern int parse_string_outer(char *s);
+extern int parse_string_outer(char *s, int end);
#endif
int gunzip (void *, int, unsigned char *, int *);
* - loaded (first part of) image to header load address,
* - disabled interrupts.
*/
-typedef void boot_os_Fcn (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[],
- ulong addr, /* of image to boot */
- ulong *len_ptr, /* multi-file image length table */
- int verify); /* getenv("verify")[0] != 'n' */
+typedef void boot_os_Fcn (cmd_tbl_t *cmdtp, bd_t *bd, int flag,
+ int argc, char *argv[],
+ ulong addr, /* of image to boot */
+ ulong *len_ptr, /* multi-file image length table */
+ int verify); /* getenv("verify")[0] != 'n' */
static boot_os_Fcn do_bootm_linux;
static boot_os_Fcn do_bootm_netbsd;
#if (CONFIG_COMMANDS & CFG_CMD_ELF)
case IH_OS_VXWORKS:
do_bootm_vxworks (cmdtp, bd, flag, argc, argv,
- addr, len_ptr, verify);
+ addr, len_ptr, verify);
break;
#endif /* CFG_CMD_ELF */
}
}
static void
-do_bootm_linux (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[],
- ulong addr,
- ulong *len_ptr,
- int verify)
+do_bootm_linux (cmd_tbl_t *cmdtp, bd_t *bd, int flag,
+ int argc, char *argv[],
+ ulong addr,
+ ulong *len_ptr,
+ int verify)
{
ulong sp;
ulong len, checksum;
}
static void
-do_bootm_netbsd (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[],
- ulong addr,
- ulong *len_ptr,
- int verify)
+do_bootm_netbsd (cmd_tbl_t *cmdtp, bd_t *bd, int flag,
+ int argc, char *argv[],
+ ulong addr,
+ ulong *len_ptr,
+ int verify)
{
image_header_t *hdr = &header;
len += strlen (argv[i]) + 1;
cmdline = malloc (len);
- for (i=2, len=0 ; i<argc ; i+=1)
- {
+ for (i=2, len=0 ; i<argc ; i+=1) {
if (i > 2)
cmdline[len++] = ' ';
strcpy (&cmdline[len], argv[i]);
#ifndef CFG_HUSH_PARSER
if (run_command (getenv ("bootcmd"), bd, flag) == -1) rcode = 1;
#else
- if (parse_string_outer(getenv("bootcmd")) != 0 ) rcode = 1;
+ if (parse_string_outer(getenv("bootcmd"), 1) != 0 ) rcode = 1;
#endif
return rcode;
}
#if (CONFIG_COMMANDS & CFG_CMD_ELF)
static void
do_bootm_vxworks (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[],
- ulong addr, ulong *len_ptr, int verify)
+ ulong addr, ulong *len_ptr, int verify)
{
image_header_t *hdr = &header;
- char str[80];
+ char str[80];
- sprintf(str, "%x", hdr->ih_ep); /* write entry-point into string */
- setenv("loadaddr", str);
- do_bootvx(cmdtp, bd, 0, 0, NULL);
+ sprintf(str, "%x", hdr->ih_ep); /* write entry-point into string */
+ setenv("loadaddr", str);
+ do_bootvx(cmdtp, bd, 0, 0, NULL);
}
#endif /* CFG_CMD_ELF */
#endif
static int parse_stream(o_string *dest, struct p_context *ctx, struct in_str *input0, int end_trigger);
/* setup: */
+static int parse_stream_outer(struct in_str *inp, int end);
#ifndef __PPCBOOT__
-static int parse_stream_outer(struct in_str *inp);
-static int parse_string_outer(const char *s);
+static int parse_string_outer(const char *s, int end);
static int parse_file_outer(FILE *f);
#else
-static int parse_stream_outer(struct in_str *inp, int end);
int ppcboot_hush_start(bd_t *bd);
-int parse_string_outer(char *s);
-static int parse_file_outer(void);
+int parse_string_outer(char *s, int end);
+int parse_file_outer(void);
#endif
#ifndef __PPCBOOT__
/* job management: */
}
if (child->sp) {
char *p1 = NULL, *p2;
+ int size = 0;
int len = 0;
- /* make new string for parser */
+ /* Fake quotation marks surrounding the echo argument */
+ if (!(strcmp(child->argv[i], "echo"))) {
+ size++;
+ if (!child->argv[i + 2]) size++;
+ }
for (n = i; child->argv[n]; n++) {
p2 = insert_var_value(child->argv[n]);
- p1 = xrealloc(p1, (len + 2 + strlen(p2)));
- strcpy(p1 + len, p2);
- strcat(p1, " ");
- len = strlen(p1);
+ p1 = xrealloc(p1, (len + 1 + strlen(p2)));
+ if (len) {
+ strcat(p1, " ");
+ } else {
+ *p1 = '\0';
+ }
+ if (n == i + 1 && size) strcat(p1, "\"");
+ strcat(p1, p2);
+ len = strlen(p1) + 2 + size;
if (p2 != child->argv[n]) free(p2);
}
- parse_string_outer(p1);
- free(p1);
- return last_return_code;
+ if (size) strcat(p1, "\"");
+ while ((p2 = strchr(p1, '\n'))) {
+ *p2 = ' ';
+ }
+ strcat(p1, "\n");
+ parse_string_outer(p1, 1);
+ free(p1);
+ return last_return_code;
}
#ifndef __PPCBOOT__
for (x = bltins; x->cmd; x++) {
if ((rpipe->r_mode == RES_IN ||
rpipe->r_mode == RES_FOR) &&
(rpipe->next == NULL)) {
- syntax();
+ syntax();
#ifdef __PPCBOOT__
flag_repeat = 0;
#endif
flag_repeat = 0;
#endif
return 1;
- }
+ }
}
for (; pi; pi = (flag_restore != 0) ? rpipe : pi->next) {
if (pi->r_mode == RES_WHILE || pi->r_mode == RES_UNTIL ||
/* most recursion does not come through here, the exeception is
* from builtin_source() */
-#ifndef __PPCBOOT__
-int parse_stream_outer(struct in_str *inp)
-#else
int parse_stream_outer(struct in_str *inp, int end)
-#endif /* __PPCBOOT__ */
{
struct p_context ctx;
o_string temp=NULL_O_STRING;
int rcode;
+#ifdef __PPCBOOT__
+ int code;
+#endif
do {
initialize_context(&ctx);
update_ifs_map();
#ifdef __PPCBOOT__
if (rcode == 1) flag_repeat = 0;
#endif
- if (rcode != 1) {
+ if (rcode != 1 && ctx.old_flag != 0) syntax();
+ if (rcode != 1 && ctx.old_flag == 0) {
done_word(&temp, &ctx);
done_pipe(&ctx,PIPE_SEQ);
#ifndef __PPCBOOT__
run_list(ctx.list_head);
#else
- rcode = run_list(ctx.list_head);
- if (rcode == -1) flag_repeat = 0;
+ if (((code = run_list(ctx.list_head)) == -1))
+ flag_repeat = 0;
#endif
} else {
if (ctx.old_flag != 0) {
free_pipe_list(ctx.list_head,0);
}
b_free(&temp);
+ } while (rcode != -1 && end != 1); /* loop on syntax errors, return on EOF */
#ifndef __PPCBOOT__
- } while (rcode != -1); /* loop on syntax errors, return on EOF */
return 0;
#else
- } while (end != 1);
- return (rcode != 1) ? 0 : 1;
+ return (code != 0) ? 1 : 0;
#endif /* __PPCBOOT__ */
}
#ifndef __PPCBOOT__
-static int parse_string_outer(const char *s)
+static int parse_string_outer(const char *s, int end)
#else
-int parse_string_outer(char *s)
+int parse_string_outer(char *s, int end)
#endif /* __PPCBOOT__ */
{
struct in_str input;
#ifdef __PPCBOOT__
if ( !s || !*s)
return 1;
- return parse_stream_outer(&input, 1);
-
-#else
- return parse_stream_outer(&input);
-#endif /* __PPCBOOT__ */
+#endif
+ return parse_stream_outer(&input, end);
}
#ifndef __PPCBOOT__
static int parse_file_outer(FILE *f)
#else
-static int parse_file_outer(void)
+int parse_file_outer(void)
#endif
{
int rcode;
struct in_str input;
#ifndef __PPCBOOT__
setup_file_in_str(&input, f);
- rcode = parse_stream_outer(&input);
#else
setup_file_in_str(&input);
+#endif
rcode = parse_stream_outer(&input, 0);
-#endif /* __PPCBOOT__ */
return rcode;
}
top_vars->next = 0;
top_vars->flg_export = 0;
top_vars->flg_read_only = 1;
- parse_file_outer();
- return 1;
+ return 0;
}
static void *xmalloc(size_t size)
{
global_argv = argv+optind;
global_argc = argc-optind;
- opt = parse_string_outer(optarg);
+ opt = parse_string_outer(optarg, 0);
goto final_return;
}
break;
}
if (done) {
res_str = xrealloc(res_str, (1 + res_str_len + strlen(inp)));
- strcat(res_str, inp);
+ strcpy((res_str + res_str_len), inp);
}
return (res_str == NULL) ? inp : res_str;
}
int len, i;
int name_len = strlen(name);
int n = 0;
- char **list = NULL;
+ char **list;
char *p1, *p2, *p3;
/* create list of variable values */
+ list = xmalloc(sizeof(*list));
for (i = 0; inp[i]; i++) {
p3 = insert_var_value(inp[i]);
p1 = p3;
#ifdef CFG_HUSH_PARSER
extern int ppcboot_hush_start(bd_t *bd);
-extern int parse_string_outer(char *s);
+extern int parse_file_outer(void);
+extern int parse_string_outer(char *s, int end);
#endif
static char * delete_char (char *buffer, char *p, int *colp, int *np, int plen);
char *p;
#endif
+#ifdef CFG_HUSH_PARSER
+ ppcboot_hush_start(bd);
+#endif
#ifdef CONFIG_PREBOOT
if ((p = getenv ("preboot")) != NULL) {
# ifdef CONFIG_AUTOBOOT_KEYED
int prev = disable_ctrlc(1); /* disable Control C checking */
# endif
+
+# ifndef CFG_HUSH_PARSER
run_command (p, bd, 0);
+# else
+ parse_string_outer(p, 1);
+# endif
+
# ifdef CONFIG_AUTOBOOT_KEYED
disable_ctrlc(prev); /* restore Control C checking */
# endif
# ifdef CONFIG_AUTOBOOT_KEYED
int prev = disable_ctrlc(1); /* disable Control C checking */
# endif
+
+# ifndef CFG_HUSH_PARSER
run_command (s, bd, 0);
+# else
+ parse_string_outer(s, 1);
+# endif
+
# ifdef CONFIG_AUTOBOOT_KEYED
disable_ctrlc(prev); /* restore Control C checking */
# endif
* Main Loop for Monitor Command Processing
*/
#ifdef CFG_HUSH_PARSER
- ppcboot_hush_start(bd);
+ parse_file_outer();
/* This point is never reached */
for (;;);
#else
#ifndef CFG_HUSH_PARSER
if (run_command (getenv (argv[i]), bd, flag) != -1) ++rcode;
#else
- if (parse_string_outer(getenv (argv[i])) == 0) ++rcode;
+ if (parse_string_outer(getenv (argv[i]), 1) == 0) ++rcode;
#endif
}
return ((rcode == i) ? 0 : 1);