Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shell escape for opening #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

oblitum
Copy link

@oblitum oblitum commented Dec 18, 2018

  • Allow opening URLs containing special chars, like quote characters
  • Selections must be strict, without surrounding whitespace

This solves one of the issues I've commented at:

Associated tmux-copycat pull request: tmux-plugins/tmux-copycat#135

- Allow opening URLs containing special chars, like quote characters
- Selections must be strict, without surrounding whitespace
inkarkat added a commit to inkarkat/tmux-open that referenced this pull request May 24, 2023
Filespec(s, on individual lines) need to be shell-quoted, as they are passed (through xargs) to the opener.
For the editor (which cannot simply be launched but needs to use the actual terminal so that the editor will be launched inside and therefore visible inside the pane), it's even worse: The concluding CR is only appended once, not for each file. Files should not be edited separately, anyway, but passed as multiple argments to a single editor instance. Also, the editor call itself should disable name lookup (send-keys -l) so that filenames that resemble a Tmux key aren't accidentally translated into a keypress.

Inspired by tmux-plugins#38 (which provides a bad solution, though).
inkarkat added a commit to inkarkat/tmux-open that referenced this pull request May 26, 2023
Filespec(s, on individual lines) need to be shell-quoted, as they are passed (through xargs) to the opener.
We need to use null-termination so that xargs doesn't do special handling of quotes. -I (implying -L 1) is _not_ enough! As our input is newline-delimited, use tr to translate to null separators, then feed to xargs -0.
For the editor (which cannot simply be launched but needs to use the actual terminal so that the editor will be launched inside and therefore visible inside the pane), it's even worse: The concluding CR is only appended once, not for each file. Files should not be edited separately, anyway, but passed as multiple argments to a single editor instance. Also, the editor call itself should disable name lookup (send-keys -l) so that filenames that resemble a Tmux key aren't accidentally translated into a keypress.

Inspired by tmux-plugins#38 (which provides a bad solution, though).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant