-bash: complete: nosort: invalid option name

Some months ago I started getting the following error whenever I’d launch bash on my Mac.

A quick Google gave me the impression it was to do with WireGuard. I do have WireGuard installed on the Mac, so I figured there’s nothing I can do and left it.

Today, I wasn’t in a mood to leave it so thought I’d try and fix it. Looks like it’s a side effect of wireguard-tools actually, which I don’t have installed. Maybe the macOS WireGuard software does something? But I couldn’t find anything in the completions folder to do with WireGuard.

On an M1 (and above) the Bash completion files are at /opt/homebrew/etc/bash_completion.d. So I went to that folder and did the following:

The -R switch means recurse; the -O switch, which I missed initially and didn’t realize was needed, tells grep to follow symbolic links. That’s important coz this folder has symbolic links and without this switch the grep command won’t do anything. What I am doing here is searching for the word “nosort” in all the files of that folder. Apparently the complete command has this invalid switch passed to it in some file.

Sure enough, I got one result:

I don’t use gpg-tui much, had installed it when I came across it somewhere. So I uninstalled it and problem was gone. If I were using gpg-tui I’d have just edited the file and removed this option I guess.