bug-bash
[Top][All Lists]
Advanced

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

Re: Enable compgen even when programmable completions are not available?


From: Robert Elz
Subject: Re: Enable compgen even when programmable completions are not available?
Date: Sat, 01 Jul 2023 12:26:48 +0700

    Date:        Fri, 30 Jun 2023 20:21:20 -0400
    From:        Eli Schwartz <eschwartz93@gmail.com>
    Message-ID:  <f7eaaa86-da53-89c4-a607-6e88705a6e03@gmail.com>

I suggested using set partly because it should work in any shell.
The need, or even ability, to set posix mode is likely to differ,
but that is minor.   In general I vastly prefer highly portable
solutions to all problems .. those tend to fail far less often,
even when just considering the evolution of a single application,
with no porting to a different one even considered.

But moving on....

  | Suggesting ways that future versions of bash 5.3 and above can do this
  | *without* hacks, would accomplish something. It would accomplish the
  | ability to migrate away from hacks and over to proper APIs.
  |
  | Maybe we should focus on that.

That's reasonable, but I would have thought a simple solution
obvious, and one which probably does not need to wait for a
new bash version (this assumes that solutions which only work
in bash are acceptable).

Simply create a loadable builtin which just prints all the
existing variable names.  If desired it could have a few
options to filter which are printed (by type, value, name,
attributes...) but doesn't need any of that.

I personally doubt there is enough demand for this functionality
for it to be a permanent builtin (until this discussion I had
never seen or heard of an actual script with a need for that
exact mechanism) but having a loadable builtin to do it sounds
entirely reasonable.   Filtering the output in the builtin might
make scripts slightly more efficient, but only when the filtering
offered is exactly what the application requires, and that is
something that is only discovered after actual use.  Everything
likely to be required can already be done given just the var
name, and suitable scripting.

You could probably even make one which could be built for,
and work in, versions of bash back to whenever the loadable
builtin facility first appeared.  (Different compiled builtins
for different bash versions, obviously.)

kre



reply via email to

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