bug-bash
[Top][All Lists]
Advanced

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

Enable compgen even when programmable completions are not available?


From: Eli Schwartz
Subject: Enable compgen even when programmable completions are not available?
Date: Sun, 25 Jun 2023 14:38:38 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.1

compgen is a useful builtin for inspecting information about the shell
context e.g. in scripts -- a good example of this is compgen -A function
or compgen -A variable.

But it's not always available depending on how bash is built, which
results in people lacking confidence that it can / should be used in
scripts. See e.g. https://bugs.gentoo.org/909148

Would it be possible to have a slightly more minimal version of it with
readline functionality and "currently inside programmable completions"
functionality stripped out, which just allows it to be used for general
environment introspection?

An alternative for compgen -A function does exist -- declare -F in
combination with e.g. sed. Variables is harder since AFAICT the only way
to print all of them prints multiline values too (declare -p is similar
to declare -f, there is no declare -P similar to declare -F, using
${!a@} to expand variable names does not work generically enough since
you need to specify a prefix -- ${!@} won't expand all of them).


-- 
Eli Schwartz



reply via email to

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