aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2022-11-26 13:22:35 +0100
committerFelix Van der Jeugt <felix.vanderjeugt@posteo.net>2023-02-12 23:19:36 +0100
commite45f573ddd592f38459591db1924c27272b2b763 (patch)
tree0be6aff8b6905d65d19122c0547d15dd92cb1f3b
parentd176a84fcdd82423aadfdbc30a66c5ed7d2e2a25 (diff)
downloadvis-e45f573ddd592f38459591db1924c27272b2b763.tar.gz
vis-e45f573ddd592f38459591db1924c27272b2b763.tar.xz
Do tilde expansion only for the tilde character at the beginning of the pattern.
-rw-r--r--vis-cmds.c6
1 files changed, 5 insertions, 1 deletions
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;
}