From: Eric Andersen Date: Thu, 5 Apr 2001 23:00:47 +0000 (-0000) Subject: Add support of /W prompts X-Git-Tag: 0_51~30 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c270ec1fa27e998d6d22bb43c3839789f8af4ba8;p=oweals%2Fbusybox.git Add support of /W prompts -Erik --- diff --git a/cmdedit.c b/cmdedit.c index e317b86fa..a3710812f 100644 --- a/cmdedit.c +++ b/cmdedit.c @@ -441,6 +441,19 @@ static void parse_prompt(const char *prmt_ptr) add_to_prompt(&prmt_mem_ptr, &alm, &prmt_len, pwd_buf); continue; #endif + case 'W': + if (pwd_buf[0] == 0) { + char *z; + + getcwd(pwd_buf, PATH_MAX); + z = strrchr(pwd_buf,'/'); + if ( (z != NULL) && (z != pwd_buf) ) { + z++; + strcpy(pwd_buf,z); + } + } + add_to_prompt(&prmt_mem_ptr, &alm, &prmt_len, pwd_buf); + continue; case '!': snprintf(buf, sizeof(buf), "%d", num_ok_lines); add_to_prompt(&prmt_mem_ptr, &alm, &prmt_len, buf); diff --git a/shell/cmdedit.c b/shell/cmdedit.c index e317b86fa..a3710812f 100644 --- a/shell/cmdedit.c +++ b/shell/cmdedit.c @@ -441,6 +441,19 @@ static void parse_prompt(const char *prmt_ptr) add_to_prompt(&prmt_mem_ptr, &alm, &prmt_len, pwd_buf); continue; #endif + case 'W': + if (pwd_buf[0] == 0) { + char *z; + + getcwd(pwd_buf, PATH_MAX); + z = strrchr(pwd_buf,'/'); + if ( (z != NULL) && (z != pwd_buf) ) { + z++; + strcpy(pwd_buf,z); + } + } + add_to_prompt(&prmt_mem_ptr, &alm, &prmt_len, pwd_buf); + continue; case '!': snprintf(buf, sizeof(buf), "%d", num_ok_lines); add_to_prompt(&prmt_mem_ptr, &alm, &prmt_len, buf);