From e45f573ddd592f38459591db1924c27272b2b763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Cepl?= Date: Sat, 26 Nov 2022 13:22:35 +0100 Subject: Do tilde expansion only for the tilde character at the beginning of the pattern. --- vis-cmds.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vis-cmds.c b/vis-cmds.c index f5221d1..a5c9f77 100644 --- 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; } -- cgit v1.2.3