-
-
Notifications
You must be signed in to change notification settings - Fork 769
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
feat(preview-tui): handle quoting in start_preview
more robustly
#1630
Conversation
Thanks! I had a similar commit laying around but there were problems and hadn't gotten around to fixing them yet. I can check windows terminal tomorrow and iterm through a VM but other testers are welcome. |
Looks OK to me (lightly tested). A couple comments:
|
This commit makes the script more resistant to naughty filenames. The script now depends on bash for the following features: - Arrays Correctly creating and passing argument lists is now simple - Parameter transformation `${parameter@Q}` makes it easy to correctly quote a string so that it can be safely re-evaluated by the interpreter later. On iTerm, the shell command used to render the preview is now passed to osascript via a named pipe: `$FIFO_OSASCRIPT`. By not embedding the shell command directly, we now no longer need to worry about osascript's quoting rules. It's not perfect, because $SHELL and $TMPDIR might contain naughty characters, but it's quite unlikely to happen.
6695ea0
to
432b075
Compare
I pushed a commit that is noticeably faster when toggling I have yet to test |
|
We can document if it's straightforward to upgrade the bash. |
Nice, that's probably faster than a manual loop. It works pretty well for me. |
af9dffb
to
7078f36
Compare
I must say I am not a big fan of writing the osascript command to a file. We already had a working solution by properly escaping that can now be replaced by two simple bash parameter expansions. The latest commit does that, what do you guys think? It works on EDIT: All working well in my testing. |
7078f36
to
d3b5d0e
Compare
Thank you! |
This PR makes the script more resistant to naughty filenames.
The script now depends on bash for the following features:
Correctly creating and passing argument lists is now simple
${parameter@Q}
makes it easy to correctly quote a string so that it can be safely re-evaluated by the interpreter later.On iTerm, the shell command used to render the preview is now passed to osascript via a named pipe:
$FIFO_OSASCRIPT
.By not embedding the shell command directly, we now no longer need to worry about osascript's quoting rules. It's not perfect, because
$SHELL
and$TMPDIR
might contain naughty characters, but it's quite unlikely to happen.Fix #1614