bug-bash
[Top][All Lists]
Advanced

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

Patch to unify shopt & set-o


From: Martin D Kealey
Subject: Patch to unify shopt & set-o
Date: Thu, 29 Aug 2024 15:58:24 +1000

Hi Chet

On Wed, 28 Aug 2024 at 23:58, Chet Ramey <chet.ramey@case.edu> wrote:

> On 8/24/24 1:46 PM, Martin D Kealey wrote:
> > I've been making some tentative patches to the `devel` branch, and since
> I
> > have a fairly large bashrc, when I compile Bash with maximal debugging
> > support, its startup is ... underwhelmingly slothful.
>
> You're seeing the memory tracing and debugging code.
>

Thanks for that.

The patch I was referring to is at
https://github.com/kurahaupo/bash/tree/patch_options and it's almost ready
to go; time to let some other eyeballs take a look at it.

The purpose of my patch is to:
1. unify the handling of set -X, set -o XXX, and shopt -s XXX, so that
either command can manipulate all options, and there's a single module
underpinning both;
2. provide a pluggable framework, so that loadable modules can register new
shopt/set -o tags (and de-register them before unloading the module);
3. gather all the logic for each option in one place, without forcing all
options to be in one file.

The code makes extensive use of designated initializers, so after merging,
it would make C11 a requirement for building Bash. Please let me know if
that's likely to be an issue.

It has involved rewriting substantial portions of of flags.[ch],
builtins/set.def, and builtins/shopt.def (around 60% of each file), and has
created options.[ch] and examples/loadables/is_prime.c; the total lines
changed is $( git diff -w -U0 devel..@ | wc -l ) == 5183 so I'm open to
making stylistic and other adjustments if that would make it easier to
merge.

It passes all the manual tests I've thrown at it, but "make test" is still
rather noisy so I have a way to go yet.

In addition to the original goals, it now includes:
* an example loadable that defines several options.
* an additional help mechanism, with new text, so that "shopt --long-help
OPTNAME" is more informative.
* a much-simplified implementation of the "compat" options, since all
options can now have computed values rather than *having* to set individual
flag variables.
* a clean up of anomalous whitespace (mostly because I kept tripping over
it every time I tried to commit with my default "paranoid" checking
enabled).
* re-indenting a few small patches, to match what appears to be your
preferred style.
* some small tweaks to quell compiler warnings.
* adjustments to xmalloc.[ch] to enable easier handling of "const"
pointers; among other things, xxfree is a clone of xfree, except that it
takes a const void* parameter instead of just void*.

I've tried to sequence the commits so that they tell a clean narrative; all
the whitespace changes are first, one commit per file, so that you can go
"git diff -w devel..ws" to reassure yourself that no other changes have
snuck in. Then the creation of the new "options" module; then integrating
it with others; then removing old stuff that's no longer required; and
finally moving the option definitions to be adjacent to the code whose
behaviour is adjusted by each option.

The last dozen or so commits are somewhat experimental, as I've adjusted
the documentation framework somewhat, so I will probably continue to clean
up and occasionally push-rebase my repo on github; please let me know when
you'd like me to *stop* doing so, so that you can grab a branch for merging.

I hope that helps your evaluation.
Are there any other administrative points I need to address?

-Martin


reply via email to

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