*d++ = *p++;
continue;
}
- if (do_special && find_cmdline_var(p, &l) >= 0 && l > 0)
+ if (do_special && find_cmdline_var(p, &l) >= 0)
{
*d++ = '\\'; // insert backslash
- do // copy the var
- *d++ = *p++;
- while (--l > 0);
+ memcpy(d, p, l); // copy the var
+ d += l;
+ p += l;
continue;
}
if (*p == '\\' && fish_like)
typedef struct spat
{
char_u *pat; // the pattern (in allocated memory) or NULL
- size_t patlen; // the length of the patten (0 is pat is NULL)
+ size_t patlen; // the length of the pattern (0 if pat is NULL)
int magic; // magicness of the pattern
int no_scs; // no smartcase for this pattern
soffset_T off;
call assert_equal("'te\\#xt'", shellescape("te#xt", 1))
call assert_equal("'te!xt'", shellescape("te!xt"))
call assert_equal("'te\\!xt'", shellescape("te!xt", 1))
+ call assert_equal("'te<cword>xt'", shellescape("te<cword>xt"))
+ call assert_equal("'te\\<cword>xt'", shellescape("te<cword>xt", 1))
+ call assert_equal("'te<cword>%xt'", shellescape("te<cword>%xt"))
+ call assert_equal("'te\\<cword>\\%xt'", shellescape("te<cword>%xt", 1))
call assert_equal("'te\nxt'", shellescape("te\nxt"))
call assert_equal("'te\\\nxt'", shellescape("te\nxt", 1))