openshift-evangelists / oc-cluster-wrapper

oc cluster up bash wrapper
Apache License 2.0
144 stars 72 forks source link

Fix profiles in bash command completion #96

Open loleary opened 6 years ago

loleary commented 6 years ago

The completion function used a hard coded reference to $HOME of the user who originally executed the command. This meant that if the root user executed oc-cluster completion bash the profiles variable would be assigned to the base names in /root/.oc/profiles/.

This change utilizes the environment variable OPENSHIFT_HOME_DIR and OPENSHIFT_PROFILES_DIR and if not set, assigns them in the same manner that oc-cluster itself does. This allows the completion script to work on a multi-user machine or when invoked by the root user for the purpose of writing the output to /etc/bash_completion.d/oc-cluster.bash.