diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2010-03-29 10:58:32 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2010-03-30 14:15:03 +0200 |
commit | 6eb741a2e1e8a956097ea59dfe573727ff11160f (patch) | |
tree | 4585d27599252b15b0be166906f4399b75f765c4 /common/hush.c | |
parent | 66e4e9242b23645c56155af0ff8ada659966ddde (diff) | |
download | barebox-6eb741a2e1e8a956097ea59dfe573727ff11160f.tar.gz barebox-6eb741a2e1e8a956097ea59dfe573727ff11160f.tar.xz |
hush: allow fancy prompts
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/hush.c')
-rw-r--r-- | common/hush.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/common/hush.c b/common/hush.c index afa67d16f5..19e35f5fa1 100644 --- a/common/hush.c +++ b/common/hush.c @@ -389,15 +389,19 @@ static int static_peek(struct in_str *i) return *i->p; } - static char *getprompt(void) { - static char *prompt; + static char prompt[PATH_MAX + 32]; - if (!prompt) - prompt = xmalloc(PATH_MAX + strlen(CONFIG_PROMPT) + 1); +#ifdef CONFIG_HUSH_FANCY_PROMPT + const char *ps1 = getenv("PS1"); + if (ps1) + process_escape_sequence(ps1, prompt, PATH_MAX + 32); + else +#endif sprintf(prompt, "%s%s ", CONFIG_PROMPT, getcwd()); + return prompt; } |