diff mbox

[U-Boot,2/2] hush: Add rudimentary support for PS1 and PS2

Message ID 1453866475-6759-2-git-send-email-marex@denx.de
State Accepted
Commit f3b267b3a229e328bf765ffbb8cb2af382bbfa63
Delegated to: Tom Rini
Headers show

Commit Message

Marek Vasut Jan. 27, 2016, 3:47 a.m. UTC
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>
---
 README            |  8 ++++++++
 common/cli_hush.c | 10 ++++++++++
 2 files changed, 18 insertions(+)

Comments

Heiko Schocher Jan. 27, 2016, 6:37 a.m. UTC | #1
Hello Marek,

Am 27.01.2016 um 04:47 schrieb Marek Vasut:
> 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>
> ---
>   README            |  8 ++++++++
>   common/cli_hush.c | 10 ++++++++++
>   2 files changed, 18 insertions(+)

Nice!

Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
>
> diff --git a/README b/README
> index ece4793..8fb25c6 100644
> --- a/README
> +++ b/README
> @@ -2894,6 +2894,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
>
> diff --git a/common/cli_hush.c b/common/cli_hush.c
> index cbaf22e..00861e2 100644
> --- a/common/cli_hush.c
> +++ b/common/cli_hush.c
> @@ -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
>
Simon Glass Jan. 27, 2016, 10:53 p.m. UTC | #2
On 26 January 2016 at 20:47, Marek Vasut <marex@denx.de> wrote:
> 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>
> ---
>  README            |  8 ++++++++
>  common/cli_hush.c | 10 ++++++++++
>  2 files changed, 18 insertions(+)
>

Reviewed-by: Simon Glass <sjg@chromium.org>
Tom Rini Feb. 8, 2016, 8:46 p.m. UTC | #3
On Wed, Jan 27, 2016 at 04:47:55AM +0100, Marek Vasut wrote:

> 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>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/README b/README
index ece4793..8fb25c6 100644
--- a/README
+++ b/README
@@ -2894,6 +2894,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
 
diff --git a/common/cli_hush.c b/common/cli_hush.c
index cbaf22e..00861e2 100644
--- a/common/cli_hush.c
+++ b/common/cli_hush.c
@@ -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