`Pane.send_keys` types nothing and raises nothing for text that starts with `-`

未关闭 适合新手
#838 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
82/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python

调研方向

阅读 src/libtmux/pane.py 中第 847 行附近 Pane.send_keys 构造 argv 的部分,并检查 Pane.cmd 如何处理 tmux 参数。使用提供的 -n hello 输入重现问题,然后确认它是否到达 pane,或者是否引发 tmux 错误。当 literal=False 和 literal=True 对以短横线开头的文本都按预期工作时,即为完成。

由索引模型根据 Issue 内容生成。

描述

bug
Summary

Pane.send_keys("-n hello") returns normally, yet nothing reaches the pane, with literal=False and with literal=True. tmux rejects the call with unknown flag -n and exit status 1. send_keys passes the text right after its own flags with no --, and does not check the result. Text that starts with - is ordinary in scripted input: command-line flags, Markdown bullets, negative numbers.

Reproduction
  1. Start a private server with a sh pane and send text that starts with -:
import libtmux
srv = libtmux.Server(socket_name="sendkeys-dash", config_file="/dev/null")
pane = srv.new_session("probe", window_command="sh").active_window.active_pane
pane.send_keys("-n hello", enter=False)
pane.send_keys("-n hello", enter=False, literal=True)
print(repr(pane.capture_pane()[-1]))
srv.kill()
  1. Send the same text through Pane.cmd with --:
proc = pane.cmd("send-keys", "-l", "--", "-n hello")
Expected

The pane shows $ -n hello, or send_keys raises with tmux's error.

Actual

The pane shows '$'. Both calls return without raising. The raw call without -- fails with command send-keys: unknown flag -n; with -- it types the text.

Environment
  • libtmux: master at 886b1cd (v0.62.0 plus 114 commits)
  • tmux: 3.8 (system build reports 3.8a)
  • Python: run with uv run --frozen from the libtmux checkout
  • OS: Linux (WSL2), private -L socket, -f /dev/null
Evidence
send_keys('-n hello', literal=False): no exception
send_keys('-n hello', literal=True): no exception
pane line after sends: '$'
pane.cmd('send-keys', ('-l', '-n hello')): returncode=1 stderr=['command send-keys: unknown flag -n']
pane.cmd('send-keys', ('-l', '--', '-n hello')): returncode=0 stderr=[]
pane line after raw sends: '$ -n hello'
References
主要语言
Python
星标
1.2k
派生
127
平均合并
2 小时 37 分钟
30 天内合并 PR
33

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

tmux-python/libtmux 的其他 Issue

查看 tmux-python/libtmux 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。