On Fri, Nov 10, 2023 at 04:42:10PM +0100, Christian Kastner wrote:
> Package: debci
> Version: 3.7
> Severity: normal
> 
> The --config option to the debci subcommands does not work:
> 
> $ mkdir /tmp/foo
> $ echo 'debci_arch="i386"' > /tmp/foo/debci.conf
> 
> $ debci config --config /tmp/foo config_dir
> config_dir=/tmp/foo
> 
> $ debci config --config /tmp/foo arch
> arch=amd64
> 
> I believe that this is because it is processed too late.
> 
> It is first processed at the top lib/environment.sh, where it is used to read
> the config, and set important variables, like debci_arch above.
> 
> Only after this has happened, its getopt(1) called. And I believe that all 
> that
> --config does at that point, is to update debci_config_dir.
> 
> 
> In fact, I believe all of the option parsing should be moved to the very top,
> as least some other options are also broken this way:
> 
> $ echo 'debci_arch_list="arm64 i386"' >> /tmp/foo/debci.conf
> $ debci config --config /tmp/foo --arch=i386 arch
> arch=i386
> $ debci config --config /tmp/foo --arch=i386 arch_list
> arch_list=amd64
> 
> 
> I didn't want to file an MR outright, as I don't know the background behind 
> the
> current solution, and there might be a good reason for it.

Some shared options are defined in lib/environment.sh, I think that's
why it currently loads lib/environment.sh before processing the command
line options.

OTH your analysis is correct, as this causes the --config option to be
useless. A solution to this would be to break the common options into
their own file, include that in the scripts, call getopt, process
--config before anything else, then load lib/environment.sh for default
values, and only then process the rest of the options.

Attachment: signature.asc
Description: PGP signature

Reply via email to