-
Notifications
You must be signed in to change notification settings - Fork 70
Open
Description
When using command completion, errors will appear in bash command completion due to oc-cluster.bash using the absolute and hard coded path from the user who executed oc-cluster completion bash.
For example, as root:
# ./oc-cluster completion bash ...
commands="up down destroy list status show ssh console plugin-list plugin-install plugin-uninstall -h --help"
profiles=$(ls -d /root/.oc/profiles/*/ | xargs -L1 basename)
boolean_args="--create-machine= --forward-ports= --metrics= --skip-registry-check= --use-existing-config="
...
This is because the assignment of profiles in the heredoc of the completion function uses the following assignment:
profiles=\$(ls -d $OPENSHIFT_PROFILES_DIR/*/ | xargs -L1 basename)
This assignment carries 2 problems.
- $OPENSHIFT_PROFILES_DIR/*/ is expanded to the value of the variable as it is defined by the oc-cluster command itself. By default, this is the user's home directory.
- If the profiles directory is empty, the ls command will fail and xargs will pass 0 arguments to basename.
The profiles assignment should instead define OPENSHIFT_PROFILES_DIR in the same manner that oc-cluster does so that it is more generic along with setting profiles to an empty string in the event that no profiles are found. For example:
ls -d "\$OPENSHIFT_PROFILES_DIR"/*/ >/dev/null 2>&1 && profiles=\$(ls -d "\$OPENSHIFT_PROFILES_DIR"/*/ | xargs -L1 basename) || profiles=''
I submitted #96 to address both of these problem.
Metadata
Metadata
Assignees
Labels
No labels