aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2021-03-17 08:33:42 +0000
committerRon Yorston <rmy@pobox.com>2021-03-17 08:54:39 +0000
commit03115cc5f17f45cfeaee22197bc6b9fff003d692 (patch)
tree95b5db7cbdbed28658d42c58ec7f9a2b5a495c61
parent3b20b4301059ed2cd457f1b6887ffcf112f1f79e (diff)
downloadbusybox-w32-03115cc5f17f45cfeaee22197bc6b9fff003d692.tar.gz
busybox-w32-03115cc5f17f45cfeaee22197bc6b9fff003d692.tar.bz2
busybox-w32-03115cc5f17f45cfeaee22197bc6b9fff003d692.zip
libbb: fix another tab-completion corner case
Commit 90f35327c (libbb: avoid problems with quoted characters in tab completion) avoided a conflict between the code to quote special characters and that to display case-preserved filenames. Here's another one. I'd installed a third-party binary on Microsoft Windows and wanted to execute it from a busybox-w32 shell which didn't have it in its path. No problem: $ c:/prog<tab> $ c:/Program<tab> Program Files/ ProgramData $ c:/Program\<tab> $ c:/PProgram I was too quick to enter the final <tab>, I'd meant to add a space. A trailing backslash is effectively removed by the tab completion matching code but it remains on the display. This confuses the code to display case-preserved filenames. Upstream BusyBox just ends up with a spurious backslash in the name. Bash rewrites the command line to remove the surplus backslash. Fix the issue in busybox-w32 by leaving the backslash in the name, even for matching purposes. This will never result in a match, thus affording the user a change to correct their mistake.
-rw-r--r--libbb/lineedit.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 205044630..c20436270 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -1046,7 +1046,13 @@ static NOINLINE int build_match_prefix(char *match_buf)
1046 1046
1047 /* Mark every \c as "quoted c" */ 1047 /* Mark every \c as "quoted c" */
1048 for (i = 0; int_buf[i]; i++) { 1048 for (i = 0; int_buf[i]; i++) {
1049#if ENABLE_PLATFORM_MINGW32
1050 /* Trailing backslash is effectively removed which confuses
1051 * the code to display case-preserved filenames. */
1052 if (int_buf[i] == '\\' && int_buf[i+1] != '\0') {
1053#else
1049 if (int_buf[i] == '\\') { 1054 if (int_buf[i] == '\\') {
1055#endif
1050 remove_chunk(int_buf, i, i + 1); 1056 remove_chunk(int_buf, i, i + 1);
1051 int_buf[i] |= QUOT; 1057 int_buf[i] |= QUOT;
1052 } 1058 }