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

Aberta Para iniciantes
#838 1 comentário 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
82/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
python

Direção de pesquisa

Leia src/libtmux/pane.py na parte da construção de argv de Pane.send_keys na linha 847 e verifique como Pane.cmd lida com argumentos do tmux. Reproduza o caso com a entrada fornecida -n hello e depois verifique se ela chega ao pane ou se o erro do tmux é gerado. O trabalho estará concluído quando literal=False e literal=True se comportarem como esperado para textos que começam com um hífen.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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
Linguagem predominante
Python
Estrelas
1.2k
Forks
127
Merge médio
2h 37min
PRs com merge (30d)
33

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de tmux-python/libtmux

Todas as issues de tmux-python/libtmux

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.