scaleway-cli icon indicating copy to clipboard operation
scaleway-cli copied to clipboard

Autocompletion script wrongly generated (at least) for bash if using path to call `scw`

Open mid1221213 opened this issue 1 year ago • 1 comments

https://github.com/scaleway/scaleway-cli/blob/d17343311bb0f7645dea2d01ecb2cb00adbacbac/internal/namespaces/autocomplete/autocomplete.go#L81

…because the basename of binaryName should be extracted. In the following test, scw is called with full path, resulting in wrongly named bash function:

$ ~/bin/scw autocomplete script shell=bash
_/home/mid/bin/scw() {
	_get_comp_words_by_ref -n = cword words

	output=$(/home/mid/bin/scw autocomplete complete bash -- "$COMP_LINE" "$cword" "${words[@]}")
	COMPREPLY=($output)
	# apply compopt option and ignore failure for older bash versions
	[[ $COMPREPLY == *= ]] && compopt -o nospace 2> /dev/null || true
	return
}
complete -F _/home/mid/bin/scw /home/mid/bin/scw

:wink:

mid1221213 avatar Feb 22 '24 19:02 mid1221213

Similar to #1959

Codelax avatar Feb 26 '24 07:02 Codelax