Re: dash bug: double-quoted "\" breaks glob protection for next char

2018-02-13 Thread Martijn Dekker
Op 13-02-18 om 14:53 schreef Denys Vlasenko:
> $ >'\'
> $ >'\'
> $ dash -c 'echo "\*"'
> \ \
> 
> The cause: uses "\\*" pattern instead of "\\\*".

Also:

$ dash -c 'case \\ab in "\*") echo BUG;; esac'
BUG
$ dash -c 'case \\a in "\?") echo BUG;; esac'
BUG

Yup. Full globbing within double quotes after a backslash.

- M.
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


dash bug: double-quoted "\" breaks glob protection for next char

2018-02-13 Thread Denys Vlasenko
$ >'\'
$ >'\'
$ dash -c 'echo "\*"'
\ \

The cause: uses "\\*" pattern instead of "\\\*".
The fix:

/* backslash */
case CBACK:
c = pgetc2();
if (c == PEOF) {
USTPUTC(CTLESC, out);
USTPUTC('\\', out);
pungetc();
} else if (c == '\n') {
nlprompt();
} else {
if (
dblquote &&
c != '\\' && c != '`' &&
c != '$' && (
c != '"' ||
eofmark != NULL
)
) {
USTPUTC(CTLESC, out); // add this line
USTPUTC('\\', out);
}
USTPUTC(CTLESC, out);
USTPUTC(c, out);
quotef++;
}
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html