gazebosim / gz-tools

Command line tools for the Gazebo libraries.
https://gazebosim.org
Apache License 2.0
14 stars 18 forks source link

Improve tab completion behavior when there are no libraries installed #106

Closed azeey closed 1 year ago

azeey commented 1 year ago

🦟 Bug fix

Summary

If only gz-tools is installed without the other gz libraries, tab completion gives strange results because the output of ign help and ign --commands is

I cannot find any available 'ign' command:
        * Did you install any ignition library?
        * Did you set the IGN_CONFIG_PATH environment variable?
            E.g.: export IGN_CONFIG_PATH=$HOME/local/share/ignition

and that's what's used to build up the list of candidates for tab completion. This PR checks if the ign help or ign --commands ran successfully, otherwise, sets the string to "" so that it does not participate in tab completion. As a result, only the help subcommand is listed as a candidate.

This PR also gets rid of a warning message:

bash: /usr/share/gz/gz*.completion.d/*.bash_completion.sh: No such file or directory

when manually sourcing the <prefix>/share/bash-completion/completions/ign script with no other gz libraries installed.

Checklist

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.