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

Đang mở Phù hợp với người mới
#838 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend-api-design, cli

Hướng nghiên cứu

Đọc src/libtmux/pane.py ở phần tạo argv của Pane.send_keys tại dòng 847 và kiểm tra cách Pane.cmd xử lý các đối số tmux. Tái hiện bằng đầu vào -n hello được cung cấp, sau đó xác minh đầu vào đó có đến được pane hay lỗi của tmux được phát sinh. Hoàn tất khi cả literal=False và literal=True đều hoạt động như mong đợi với văn bản bắt đầu bằng dấu gạch ngang.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
Ngôn ngữ chính
Python
Star
1.2k
Fork
127
Merge trung bình
2 giờ 37 phút
Pull request đã merge (30 ngày)
33

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của tmux-python/libtmux

Tất cả issue của tmux-python/libtmux

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.