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

オープン 初心者向け
#838 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
82/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python

調査の方向性

847行目にある Pane.send_keys の argv 構築箇所を中心に src/libtmux/pane.py を読み、Pane.cmd が tmux の引数をどう扱うかを確認してください。提示された -n hello の入力で再現し、その入力がペインに届くか、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分
マージ済み PR(30日)
33

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

tmux-python/libtmux のほかの issue

tmux-python/libtmux の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。