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

Ouverte Adaptée aux débutants
#838 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
2/5
Temps estimé
1-3 heures
Accessibilité débutants
82/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
python

Piste de recherche

Lis src/libtmux/pane.py autour de la construction de argv de Pane.send_keys à la ligne 847 et vérifie comment Pane.cmd traite les arguments de tmux. Reproduis le cas avec l’entrée fournie -n hello, puis vérifie si elle atteint le pane ou si l’erreur de tmux est déclenchée. Le travail est terminé lorsque literal=False et literal=True se comportent comme prévu avec un texte commençant par un tiret.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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
Langage dominant
Python
Étoiles
1.2k
Forks
127
Merge moyen
2 h 37 min
PR mergées (30 j)
33

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de tmux-python/libtmux

Toutes les issues de tmux-python/libtmux

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.