The variable rl_ignore_completion_duplicates is a global with static
lifetime, so it's set to 1 during program loading. It looks like your code
sets it to 0 or 1 when «-o nosort» or «+o nosort» is supplied, but does not
set it to the default if neither is supplied. So I expect every subsequent
invocation of compgen, tab completion, etc to use the most recently applied
«±o nosort» rather than the default.

In any case, I can see sorting with or without duplicate suppression being
useful, which suggests that this should be a new separate option, not an
overloading of nosort; perhaps «+o dedup?»

-Martin

On Mon, 23 Feb 2026 at 00:18, <[email protected]> wrote:

> Do you think this is reasonable? Any downsides?
>
> --- bash-5.3/pcomplete.c        2024-07-09 23:38:54.000000000 +0800
> +++ bash-5.3a/pcomplete.c       2026-02-22 20:37:00.272792797 +0800
> @@ -1471,8 +1471,10 @@
>    if (flags & COPT_NOQUOTE)
>      rl_filename_quoting_desired = 1 - nval;
>    /* Ditto */
> -  if (flags & COPT_NOSORT)
> +  if (flags & COPT_NOSORT) {
>      rl_sort_completion_matches = 1 - nval;
> +    rl_ignore_completion_duplicates = 1 - nval;
> +  }
>  }
>
>  /* Set or unset FLAGS in the options word of the current compspec.

Reply via email to