Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

profiles fail to be read during bash command completion #97

Open
loleary opened this issue Sep 11, 2018 · 0 comments
Open

profiles fail to be read during bash command completion #97

loleary opened this issue Sep 11, 2018 · 0 comments

Comments

@loleary
Copy link

loleary commented Sep 11, 2018

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.

  1. $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.
  2. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant