]> git.karo-electronics.de Git - karo-tx-uboot.git/commitdiff
hush: Add rudimentary support for PS1 and PS2
authorMarek Vasut <marex@denx.de>
Wed, 27 Jan 2016 03:47:55 +0000 (04:47 +0100)
committerTom Rini <trini@konsulko.com>
Mon, 8 Feb 2016 15:10:37 +0000 (10:10 -0500)
Add trivial support for changing the U-Boot command prompt string
by setting PS1 and PS2 environment variables. Only static variables
are supported.

Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Heiko Schocher <hs@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
README
common/cli_hush.c

diff --git a/README b/README
index 83d2874851cf2e9aba97d01c007644e50c9f3509..2492364b6d5a666768beb5aa132eade517fe35be 100644 (file)
--- a/README
+++ b/README
@@ -2905,6 +2905,14 @@ CBFS (Coreboot Filesystem) support
                Enable editing and History functions for interactive
                command line input operations
 
+- Command Line PS1/PS2 support:
+               CONFIG_CMDLINE_PS_SUPPORT
+
+               Enable support for changing the command prompt string
+               at run-time. Only static string is supported so far.
+               The string is obtained from environment variables PS1
+               and PS2.
+
 - Default Environment:
                CONFIG_EXTRA_ENV_SETTINGS
 
index cbaf22e9129a7078a0912067e92c536b84eadd87..00861e2d9e4b56c114a4dcae71fdbb0f89a996aa 100644 (file)
@@ -978,12 +978,22 @@ static inline void setup_prompt_string(int promptmode, char **prompt_str)
 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