X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=common%2Fcli_hush.c;h=00861e2d9e4b56c114a4dcae71fdbb0f89a996aa;hb=4101f6879256720b30df712089a3df18565f9203;hp=f075459911e02f714d39d1f45020fabc52991962;hpb=aa722529635c16c52d9d609122fecc96ec8d03e4;p=oweals%2Fu-boot.git diff --git a/common/cli_hush.c b/common/cli_hush.c index f075459911..00861e2d9e 100644 --- a/common/cli_hush.c +++ b/common/cli_hush.c @@ -974,6 +974,30 @@ static inline void setup_prompt_string(int promptmode, char **prompt_str) } #endif +#ifdef __U_BOOT__ +static int uboot_cli_readline(struct in_str *i) +{ + char *prompt; + char __maybe_unused *ps_prompt = NULL; + + if (i->promptmode == 1) + prompt = CONFIG_SYS_PROMPT; + else + prompt = CONFIG_SYS_PROMPT_HUSH_PS2; + +#ifdef CONFIG_CMDLINE_PS_SUPPORT + if (i->promptmode == 1) + ps_prompt = getenv("PS1"); + else + ps_prompt = getenv("PS2"); + if (ps_prompt) + prompt = ps_prompt; +#endif + + return cli_readline(prompt); +} +#endif + static void get_user_input(struct in_str *i) { #ifndef __U_BOOT__ @@ -1003,11 +1027,8 @@ static void get_user_input(struct in_str *i) bootretry_reset_cmd_timeout(); i->__promptme = 1; - if (i->promptmode == 1) { - n = cli_readline(CONFIG_SYS_PROMPT); - } else { - n = cli_readline(CONFIG_SYS_PROMPT_HUSH_PS2); - } + n = uboot_cli_readline(i); + #ifdef CONFIG_BOOT_RETRY_TIME if (n == -2) { puts("\nTimeout waiting for command\n"); @@ -2471,11 +2492,16 @@ static int done_word(o_string *dest, struct p_context *ctx) } argc = ++child->argc; child->argv = realloc(child->argv, (argc+1)*sizeof(*child->argv)); - if (child->argv == NULL) return 1; + if (child->argv == NULL) { + free(str); + return 1; + } child->argv_nonnull = realloc(child->argv_nonnull, (argc+1)*sizeof(*child->argv_nonnull)); - if (child->argv_nonnull == NULL) + if (child->argv_nonnull == NULL) { + free(str); return 1; + } child->argv[argc-1]=str; child->argv_nonnull[argc-1] = dest->nonnull; child->argv[argc]=NULL; @@ -3503,9 +3529,9 @@ static char *insert_var_value_sub(char *inp, int tag_subst) char *p, *p1, *res_str = NULL; while ((p = strchr(inp, SPECIAL_VAR_SYMBOL))) { - /* check the beginning of the string for normal charachters */ + /* check the beginning of the string for normal characters */ if (p != inp) { - /* copy any charachters to the result string */ + /* copy any characters to the result string */ len = p - inp; res_str = xrealloc(res_str, (res_str_len + len)); strncpy((res_str + res_str_len), inp, len);