From 4142f0187dcf8454e8d2a8d16b321dbd573c170e Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 5 Jul 2017 22:19:28 +0200 Subject: ash: fix escaping of a few characters (broken by last commits) Add a testcase which tests all ASCII punctuation escapes. NB: hush is failing this test! Signed-off-by: Denys Vlasenko --- shell/ash.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'shell/ash.c') diff --git a/shell/ash.c b/shell/ash.c index 9b1f579..946e872 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -5939,12 +5939,17 @@ rmescapes(char *str, int flag) * (for example, glibc <= 2.22). * * Lets add "\" only on the chars which need it. + * Testcases for less obvious chars are shown. */ if (*p == '*' || *p == '?' || *p == '[' - /* || *p == ']' maybe also this? */ - || *p == '\\' + || *p == '\\' /* case '\' in \\ ) echo ok;; *) echo WRONG;; esac */ + || *p == ']' /* case ']' in [a\]] ) echo ok;; *) echo WRONG;; esac */ + || *p == '-' /* case '-' in [a\-c]) echo ok;; *) echo WRONG;; esac */ + || *p == '!' /* case '!' in [\!] ) echo ok;; *) echo WRONG;; esac */ + /* Some libc support [^negate], that's why "^" also needs love */ + || *p == '^' /* case '^' in [\^] ) echo ok;; *) echo WRONG;; esac */ ) { *q++ = '\\'; } -- cgit v1.1