Keep completion words out of shell evaluation

This commit is contained in:
2026-11-03 13:09:00 +00:00
parent c205903900
commit 8b48115328
4 changed files with 131 additions and 11 deletions

View File

@@ -30,6 +30,15 @@ elif shell == "fish":
else:
raise SystemExit(f"unsupported shell: {shell}")
tab_only = os.environ.get("PROBE_TAB_ONLY") == "1"
if tab_only:
if shell == "zsh":
setup += "; function ck_tab_done { print CK_TAB_FINISHED; }; zle -N ck_tab_done; bindkey '^X^T' ck_tab_done"
elif shell == "bash":
setup += r"""; bind -x '"\C-x\C-t": "printf CK_TAB_FINISHED"'"""
else:
raise SystemExit("tab-only probe requires Bash or Zsh")
child = pexpect.spawn(executable, args, env=os.environ.copy(), cwd=os.environ["PROBE_DIR"],
encoding="utf-8", timeout=15, dimensions=(24, 120))
child.delaybeforesend = 0.05
@@ -39,7 +48,11 @@ try:
child.expect_exact("PROMPT> ")
child.send(line)
child.send("\t")
if os.environ.get("PROBE_LIST") == "1":
if tab_only:
child.sendcontrol("x")
child.sendcontrol("t")
child.expect_exact("CK_TAB_FINISHED")
elif os.environ.get("PROBE_LIST") == "1":
child.send("\t")
remaining = ["Readable text", "YAML output"]
captured = []