FIGNORE not effective if it contains a full filename

0 views
Skip to first unread message

Josh Triplett

unread,
Aug 19, 2020, 3:16:14 PM8/19/20
to bug-...@gnu.org
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2 -fdebug-prefix-map=/build/bash-vu7ylu/bash-5.0=. -fstack-protector-strong -Wformat -Werror=format-security -Wall -Wno-parentheses -Wno-format-security
uname output: Linux s 5.7.0-2-amd64 #1 SMP Debian 5.7.10-1 (2020-07-26) x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 5.0
Patch Level: 18
Release Status: release

Description:
If FIGNORE contains the complete filename of a file, tab
completion will not ignore it.

Repeat-By:
First, `touch Cargo.{toml,lock}` to create a pair of files with a
common prefix. (These two names commonly appear side-by-side in Rust
projects, and you almost always want to tab-complete Cargo.toml, not
Cargo.lock.)

To test the baseline behavior, type `echo C` and press tab; bash
will complete "Cargo." and wait for more input.

Set FIGNORE=lock and try again; bash ignores Cargo.lock and
completes Cargo.toml.

Set FIGNORE=argo.lock and try again; bash again ignores
Cargo.lock and completes Cargo.toml.

Set FIGNORE=Cargo.lock and try again; bash just completes
"Cargo." and waits for more input.

Chet Ramey

unread,
Aug 19, 2020, 3:34:00 PM8/19/20
to Josh Triplett, bug-...@gnu.org, chet....@case.edu
On 8/19/20 3:15 PM, Josh Triplett wrote:

> Bash Version: 5.0
> Patch Level: 18
> Release Status: release
>
> Description:
> If FIGNORE contains the complete filename of a file, tab
> completion will not ignore it.

FIGNORE is a list of suffixes, and requires at least one character before
the suffix when matching.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU ch...@case.edu http://tiswww.cwru.edu/~chet/

Josh Triplett

unread,
Aug 19, 2020, 4:01:48 PM8/19/20
to Chet Ramey, bug-...@gnu.org
On Wed, Aug 19, 2020 at 03:33:49PM -0400, Chet Ramey wrote:
> On 8/19/20 3:15 PM, Josh Triplett wrote:
>
> > Bash Version: 5.0
> > Patch Level: 18
> > Release Status: release
> >
> > Description:
> > If FIGNORE contains the complete filename of a file, tab
> > completion will not ignore it.
>
> FIGNORE is a list of suffixes, and requires at least one character before
> the suffix when matching.

I'm wondering if either that might be changeable or there could be a way
to specify full filenames to get the same treatment. I'd like to ignore
specific filenames, rather than all filenames ending in a suffix. Or
perhaps there could be an option that does a regex match (allowing
things like ^ and $)?

Chet Ramey

unread,
Aug 19, 2020, 4:21:12 PM8/19/20
to Josh Triplett, chet....@case.edu, bug-...@gnu.org
On 8/19/20 4:01 PM, Josh Triplett wrote:
> On Wed, Aug 19, 2020 at 03:33:49PM -0400, Chet Ramey wrote:
>> On 8/19/20 3:15 PM, Josh Triplett wrote:
>>
>>> Bash Version: 5.0
>>> Patch Level: 18
>>> Release Status: release
>>>
>>> Description:
>>> If FIGNORE contains the complete filename of a file, tab
>>> completion will not ignore it.
>>
>> FIGNORE is a list of suffixes, and requires at least one character before
>> the suffix when matching.
>
> I'm wondering if either that might be changeable or there could be a way
> to specify full filenames to get the same treatment.

FIGNORE has behaved this way for 30 years, so there's not much chance that
behavior will change.

> I'd like to ignore
> specific filenames, rather than all filenames ending in a suffix. Or
> perhaps there could be an option that does a regex match (allowing
> things like ^ and $)?

You can do this with programmable completion, but you have to go through
the effort of defining the compspecs for the commands of interest. Or
you can use it in the default programmable completion (complete -D).
Reply all
Reply to author
Forward
0 new messages