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

Improved lmod_bash_completions #157

Merged
merged 4 commits into from
Aug 31, 2016
Merged

Improved lmod_bash_completions #157

merged 4 commits into from
Aug 31, 2016

Conversation

pneerincx
Copy link
Contributor

  • Added support for ${LMOD_REDIRECT}
  • Fixed bug where "ml rm " would list all available modules as opposed to loaded ones that can be removed.
  • Indentation used a mix of tabs and spaces: standardized for now on tabs for indentation.

… bug where ml rm <TAB> would list all available module as opposed to loaded ones that can be removed.
Regular pull from blessed master.
COMPREPLY=( $(IFS=: compgen -W "${MODULEPATH}" -- "${cur}") )
;;
use|*-a*)
_filedir -d || return 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pneerincx: We recently noticed that tab completion on use requires _filedir, which is not available by default in bash (it's not a builtin like compgen is), but is provided by a separate package (e.g. bash-completion on SL6)

Wouldn't it be better to check whether _filedir is defined rather than using it blindly?

I think that's what the return 0 is about, but it doesn't do what it's intended to do.
Here's what I get on a system that doesn't have _filedir with ml use /user<tab>:

$ ml use /user-bash: _filedir: command not found

Copy link
Contributor Author

@pneerincx pneerincx Aug 31, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@boegel: I did not touch that part of the code (except for cleaning up the indentation/formatting), but agree that it would be better not to rely on non-standard bash add-ons. This problem was reported as issue #86

COMPREPLY[0]="${dir}/"
compopt -o nospace
fi
fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pneerincx wouldn't it be cleaner to define a dedicated function for this, rather than copy-pasting it?

@rtmclay rtmclay merged commit 08567ca into TACC:master Aug 31, 2016
rtmclay pushed a commit that referenced this pull request Aug 31, 2016
@rtmclay
Copy link
Member

rtmclay commented Aug 31, 2016

Thanks very much for the patch. Coming up with a way to handle sites that do not have _filedir is a great fix (repairing #86)!

I prefer the indentation that was already in the original so I have reverted it. I do agree that mixing tabs and spaces is a bad idea so I have marked the file to only use spaces for indentation. I also took @boegel suggestion to combine the duplicated code into a single function called _module_filedir()

This is fix is marked as Lmod 6.5.5. Please test this new version when you get a chance.

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

Successfully merging this pull request may close these issues.

3 participants