help-bash
[Top][All Lists]
Advanced

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

How do I enable globstar behavior with completion?


From: Steve
Subject: How do I enable globstar behavior with completion?
Date: Wed, 13 Apr 2022 23:37:23 +0100
User-agent: Roundcube Webmail/1.3.3

Hi,

In an effort to create a custom bash completion script, I discovered the `-G` option for compgen/complete.

Unfortunately, it seems like this option does not take into consideration the globstar shopt. For instance:

$ mkdir -p a/b/c/
$ touch a/b/c/{1,2,3}.txt
$ shopt -p globstar
shopt -s globstar
$ ls a/**/*.txt
a/b/c/1.txt  a/b/c/2.txt  a/b/c/3.txt
$ compgen -G"a/**/*.txt"
$ compgen -G"a/*/*/*.txt"
a/b/c/1.txt
a/b/c/2.txt
a/b/c/3.txt

$ bash --version
GNU bash, version 5.1.8(1)-release (x86_64-redhat-linux-gnu)

Is there something I need to enable/set for the -G option for compgen/complete to behave the same way as globbing works on the commandline with globstar set ? Or is my expectation incorrect ?

Thanks and regards,
Steve



reply via email to

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