bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] FIGNORE: ignore results that are exactly equal to a suffix


From: Emanuele Torre
Subject: [PATCH] FIGNORE: ignore results that are exactly equal to a suffix
Date: Mon, 17 Apr 2023 04:08:55 +0200

FIGNORE makes bash only ignore filename completion results that end with
one of the specified suffixes and are not exactly equal to the suffix.

So, for example,  FIGNORE=xyz   will ignore `abcxyz', and `xyzxyz', but
not `xyz'.

>From the documentation it is not clear that FIGNORE should work this
way, and there are legitimate use cases that need FIGNORE to ignore a
file that matches exactly the suffix (for example, FIGNORE=.DS_Store;
though FIGNORE=DS_Store would also work.)

I think it makes sense to change the behaviour of FIGNORE to also ignore
results that are exactly equal one of the suffix.
Alternatively, I think the documentation should be updated to clarify
that files don't match FIGNORE suffixes that are exactly equal to their
name.
---
 bashline.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bashline.c b/bashline.c
index 37cc48a9..64401d29 100644
--- a/bashline.c
+++ b/bashline.c
@@ -3070,7 +3070,7 @@ name_is_acceptable (const char *name)
 
   for (nlen = strlen (name), p = fignore.ignores; p->val; p++)
     {
-      if (nlen > p->len && p->len > 0 && STREQ (p->val, &name[nlen - p->len]))
+      if (nlen >= p->len && p->len > 0 && STREQ (p->val, &name[nlen - p->len]))
        return (0);
     }
 
-- 
2.40.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]