xonsh/xonsh

if _get_bash_completions_source() is None, 'set()' gets into bash completion script

Closed this issue · 7 comments

Once again, this is a borderline non-issue.

I'm running NixOS, which does not follow FHS and _get_bash_completions_source() returns None there.

While debugging the resulting lack of bash completion, I stumbled upon

source = _get_bash_completions_source(paths) or set()

which gets interpolated here

source = _get_bash_completions_source(paths) or set()

and sure enough, the bash script now starts with set().

I'm sure that was not @scopatz's original intention.

Thanks for reporting @t184256! Aren't those the same lines?

Sorry, the second one was meant to be

Ahh I see. This should probably raised over at https://github.com/xonsh/py-bash-completion, since xonsh vends this package here. We can keep this issue open until that is resolved though.

On NixOS, what does import platform; platform.system() say? And where do the bash completion scripts live?

On NixOS, what does import platform; platform.system() say?

Linux

And where do the bash completion scripts live?

The main one that we're trying to source here? It lives inside the bash-completion package with an unpredictable path, and the philosophically correct way to point xonsh there should be build-time source patching, a la

substituteInPlace xonsh/platform.py --replace \
    '/usr/share/bash-completion/bash_completion' \
    '${pkgs.bash-completion}/etc/profile.d/bash_completion.sh'

It's not a bug, it's a feature. Don't lose much sleep over NixOS support, it's something that should be done on their side, not yours.

Actually, a quick question while we're on that topic.

What are the downsides of throwing out all that path guessing logic and replacing line 206 with a simple PS1=make_bash_think_it_is_interactive source /etc/bashrc?

Execution time, mainly. When I was timing it a couple of years ago it was the difference between 10 us and 10 ms, IIRC. And since this something that gets run when people press TAB, it should be as fast as possible

Reasonable. Then, could we either:

  1. Drop a hint in $BASH_COMPLETIONS doc that systemwide bashrc is fine too?
  2. Go ahead and append several guesses to the bcds as a fallback?