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 <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2017-07-05 22:19:28 +02:00
parent ed79a63623
commit 4142f0187d
3 changed files with 83 additions and 2 deletions

View File

@ -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++ = '\\';
}