dundalek/closh

shell completion bugs

johannesloetzsch opened this issue · 2 comments

Tab completion for shell commands didn't work for me (using the java version of closh in combination with bash). So I searched for the reason and found two:

  1. resources/completion/completion.bash couldn't find _completion_loader. My distribution doesn't provide bash_completion* at one of the nasty hard coded paths. _completion_loader is exactly than available, when bash is started in interactive mode.

  2. clojure-completer at src/jvm/closh/zero/frontend/rebel.clj contains the following checks:

(not (string/blank? word))
(pos? (count word))

I don't see how (pos? (count word)) could be false when (not (string/blank? word)).

When running the completion on the line „ls “ (be aware of the space at the end) I would expect to receive all files in the current directory to be returned as candidates. However word is empty and so the completion doesn't return anything.
I'm not completely sure, why this conditions are there at all, but probably they should either be substituted by (not (string/blank? (.line line))) or they should only be applied to clj-completions but not shell-completions?

The check was taken when I adapted the code from rebel-readline: https://github.com/bhauman/rebel-readline/blob/master/rebel-readline/src/rebel_readline/clojure/line_reader.clj#L998

We can probably change if it makes more sense to do it differently. The "ls " example makes sense and it also works that way in the clojurescript version.

Thanx :)