Make CLI completion generation dynamic, not hard-coded - #1285
Conversation
088a1aa to
caa4174
Compare
| if "FISH_VERSION" in os.environ: | ||
| cls = FishComplete | ||
| elif "ZSH_VERSION" in os.environ: | ||
| cls = ZshComplete |
There was a problem hiding this comment.
Can we restore the older zsh check? If you prefer, we could make it the behavior for all three shells.
I have a stock install of zsh as my login shell, and no ZSH_VERSION variable is present.
I've forgotten most of the details about the shell behaviors for these variables, but they aren't guaranteed to be present. (And, of course, if I run bash from a zsh session, I get SHELL=/bin/zsh, and vice-versa for a bash shell session with SHELL=/bin/bash! So it's not possible to do it right all of the time.)
There was a problem hiding this comment.
The zsh docs suggested that ZSH_VERSION was guaranteed to be set by the shell, so I cannot account for this discrepancy. Further, I found that when I ran fish locally, it inherited SHELL=/usr/bin/bash, which made me think that this wasn't reliable.
It's far more preferable to remove the auto-detection logic, but since that's not the point of this PR I've added back in the SHELL-based check.
There was a problem hiding this comment.
Well, crumbs. Turns out ZSH_VERSION and FISH_VERSION don't seem to operate as exported environment variables, so they can't be relied on. Pulled that code entirely out.
There was a problem hiding this comment.
Breadcrumb for time-travelers:
We figured things out a bit more. The version vars aren't exported by shells, so they're probably never set in the python process. Probably this "just doesn't work", but nobody has noticed because the SHELL-reading works well enough.
caa4174 to
7cc3305
Compare
7cc3305 to
76867de
Compare
Exactly what it says on the tin.