Bash completion: _binary_arch is unnecessary and causes the first completion attempt to error
Invoking the pkgctl
completion on bash gives a bash: -1: substring expression < 0
error on the first attempt. Subsequent attempts work flawlessly, though.
Looking this up, the culprit appears to be https://gitlab.archlinux.org/archlinux/devtools/-/blob/master/contrib/completion/bash/devtools.in?ref_type=heads#L17.
In fact, it is unnecessary, and is unreferenced anywhere in that script (indeed, _binary_arch
only appears once more in the repo, in the zsh completion).
The problem is that its setting is invalid bash syntax -- while zsh allows slicing with negative endpoints for both strings and arrays, bash only allows it for strings. The valid bash spelling for this would be ${arr[*]:0:${#arr[*]}-1}
, but as indicated, the variable is not even necessary.
It seems the line was pulled in in f961e2e9 by porting the zsh completion, which probably missed the zshism.