diff options
author | Denys Vlasenko | 2013-03-28 13:20:12 +0100 |
---|---|---|
committer | Denys Vlasenko | 2013-03-28 13:20:12 +0100 |
commit | 6c852bfcadd78f53ec7a5f35882636a2a4a66eb0 (patch) | |
tree | d70511de9bde3fcefa3e8a60dee33a9c0882459e /libbb | |
parent | 2c24806bf48cddcdaa32d654986e5c275a3d34f6 (diff) | |
download | busybox-6c852bfcadd78f53ec7a5f35882636a2a4a66eb0.zip busybox-6c852bfcadd78f53ec7a5f35882636a2a4a66eb0.tar.gz |
lineedit: add handling of \H in prompt
Based on the patch by Arnaud RĂ©billout <rebillout@syscom.ch>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/lineedit.c | 50 |
1 files changed, 45 insertions, 5 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 52b49e8..591bb6d 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c @@ -1789,7 +1789,44 @@ static void parse_and_put_prompt(const char *prmt_ptr) if (c == '\\') { const char *cp = prmt_ptr; int l; - +/* + * Supported via bb_process_escape_sequence: + * \a ASCII bell character (07) + * \e ASCII escape character (033) + * \n newline + * \r carriage return + * \\ backslash + * \nnn char with octal code nnn + * Supported: + * \$ if the effective UID is 0, a #, otherwise a $ + * \! history number of this command + * (buggy?) + * \w current working directory, with $HOME abbreviated with a tilde + * Note: we do not support $PROMPT_DIRTRIM=n feature + * \h hostname up to the first '.' + * \H hostname + * \u username + * \[ begin a sequence of non-printing characters + * \] end a sequence of non-printing characters + * Not supported: + * \# command number of this command + * \j number of jobs currently managed by the shell + * \l basename of the shell's terminal device name + * \s name of the shell, the basename of $0 (the portion following the final slash) + * \V release of bash, version + patch level (e.g., 2.00.0) + * \W basename of the current working directory, with $HOME abbreviated with a tilde + * \d date in "Weekday Month Date" format (e.g., "Tue May 26") + * \D{format} + * format is passed to strftime(3). + * An empty format results in a locale-specific time representation. + * The braces are required. + * \T current time in 12-hour HH:MM:SS format + * \@ current time in 12-hour am/pm format + * \A current time in 24-hour HH:MM format + * Mishandled by bb_process_escape_sequence: + * \t current time in 24-hour HH:MM:SS format + * \v version of bash (e.g., 2.00) + */ c = bb_process_escape_sequence(&prmt_ptr); if (prmt_ptr == cp) { if (*cp == '\0') @@ -1802,9 +1839,11 @@ static void parse_and_put_prompt(const char *prmt_ptr) pbuf = user_buf ? user_buf : (char*)""; break; # endif + case 'H': case 'h': pbuf = free_me = safe_gethostname(); - *strchrnul(pbuf, '.') = '\0'; + if (c == 'h') + strchrnul(pbuf, '.')[0] = '\0'; break; case '$': c = (geteuid() == 0 ? '#' : '$'); @@ -1832,9 +1871,10 @@ static void parse_and_put_prompt(const char *prmt_ptr) case '!': pbuf = free_me = xasprintf("%d", num_ok_lines); break; - case 'e': case 'E': /* \e \E = \033 */ - c = '\033'; - break; +// bb_process_escape_sequence does this now: +// case 'e': case 'E': /* \e \E = \033 */ +// c = '\033'; +// break; case 'x': case 'X': { char buf2[4]; for (l = 0; l < 3;) { |