forked from skim-rs/skim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix skim-rs#90 escape single quote in preview command
The placeholder in preview command will be replaced by single quoted selected item. However if the preview command itself includes single quote, the result won't work. e.g. command `echo {}` given item `'` would results in `echo '''` that is not a valid shell command. Unfortunately there is no easy way to escape single quote in shell. So we apply the hack: turn single quote `'` to `'\''` that terminate the first quote and insert an escaped quote and another starting quote.
- Loading branch information
Showing
4 changed files
with
37 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ mod query; | |
mod reader; | ||
mod score; | ||
mod sender; | ||
mod util; | ||
|
||
use curses::Curses; | ||
use event::Event::*; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub fn escape_single_quote(text: &str) -> String { | ||
text.replace("'", "'\\''") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters