diff --git a/src/expand.c b/src/expand.c index 2a50830..af88a69 100644 --- a/src/expand.c +++ b/src/expand.c @@ -1686,12 +1686,17 @@ _rmescapes(char *str, int flag) } if (*p == (char)CTLESC) { p++; - if (notescaped) - *q++ = '\\'; - } else if (*p == '\\' && !inquotes) { - /* naked back slash */ - notescaped = 0; - goto copy; + goto escape; + } else if (*p == '\\') { + if (inquotes) { +escape: + if (notescaped) + *q++ = '\\'; + } else { + /* naked back slash */ + notescaped = 0; + goto copy; + } } notescaped = globbing; copy: