alacritty / alacritty

A cross-platform, OpenGL terminal emulator.
https://alacritty.org
Apache License 2.0
53.22k stars 2.93k forks source link

-bash: complete: nosort: invalid option name sourcing alacritty.bash completion file on MacOS #7949

Open diogomatsubara opened 2 weeks ago

diogomatsubara commented 2 weeks ago

In commit https://github.com/alacritty/alacritty/commit/59c63d373804fe9d00d92d2dd47174d4e1637333, the bash complete script (alacritty.bash) was changed and includes in line 368 the -o nosort option. Unfortunately that option is not available in the default bash shell shipped by MacOS (3.2.57(1)-release) and I end up getting the following message when I source the file:

-bash: complete: nosort: invalid option name

For example, projects that use the go-lang cobra command to generate the completion file (e.g. yq) take into account the bash version to enable or not the nosort option (see https://github.com/spf13/cobra/blob/v1.8.0/bash_completionsV2.go#L120-L130).

It'd be nice to have a similar logic in alacritty.bash to avoid this error.

System

OS: macOS 14.4.1 (23E224) Version: alacritty 0.13.2 (bb8ea18) Bash: 3.2.57(1)-release

Logs

To reproduce source the alacritty.bash on MacOS with bash 3.2.57(1)-release

$ . alacritty.bash
-bash: complete: nosort: invalid option name
kchibisov commented 2 weeks ago

@chrisduerr I'm pretty sure this part of completions is also auto generated, thus it should be brought to clap?

It should likely do a version check or something and not emit the option by default. Though, macOS users better just install bash from e.g. brew, because apple don't generally care about gplv3 stuff and not sure they even security bug fix it.

diogomatsubara commented 2 weeks ago

@kchibisov thanks for the quick reply!

It seems this was fixed in clap more recent version 4.5.4 https://github.com/clap-rs/clap/commit/2b48858ba84c62e9af97bee4734d70530254cd8a but alacritty uses 4.4.11 (https://github.com/alacritty/alacritty/blob/master/Cargo.lock#L349)

chrisduerr commented 2 weeks ago

If only macOS would actually update their software…