vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 217d074fec6720eed71d58da94426fe595e862ae
parent 806cbb1309c7db59f4cd874bc217d92a8fb938f9
Author: Matěj Cepl <mcepl@cepl.eu>
Date:   Sat, 26 Nov 2022 13:22:35 +0100

Do tilde expansion only for the tilde character at the beginning of the pattern.

Diffstat:
Mvis-cmds.c | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/vis-cmds.c b/vis-cmds.c @@ -379,7 +379,11 @@ static bool is_file_pattern(const char *pattern) { struct stat meta; if (stat(pattern, &meta) == 0 && S_ISDIR(meta.st_mode)) return true; - for (char special[] = "*?[{$~", *s = special; *s; s++) { + /* tilde expansion is defined only for the tilde at the + beginning of the pattern. */ + if (pattern[0] == '~') + return true; + for (char special[] = "*?[{$", *s = special; *s; s++) { if (strchr(pattern, *s)) return true; }