mirror of
https://github.com/vale981/tridactyl
synced 2025-03-04 17:11:40 -05:00
native_background.ts: Fix clipboard() adding newlines to copied strings
Here-documents require a newline at the end of their content and there's no way around it. In order to prevent the newline to be sent to the clipboard command, we can do two things: not use here-documents or pipe the content to sed first to remove the newline. Not using here-documents means doing a lot of string manipulations to escape the string properly. Using here-documents is conceptually simpler. Hence, we keep using here-documents and pipe the string to sed in order to remove the newline.
This commit is contained in:
parent
2a43d0b910
commit
4a5dcd7557
1 changed files with 2 additions and 1 deletions
|
@ -315,7 +315,8 @@ export async function clipboard(
|
|||
heredoc += Math.round(Math.random() * 10)
|
||||
|
||||
// Use delimiter to insert str into clipcmd's stdin
|
||||
clipcmd = `${clipcmd} -i <<'${heredoc}'\n${str}\n${heredoc}\n`
|
||||
// We use sed to remove the newline added by the here document
|
||||
clipcmd = `sed -z 's/.$//' <<'${heredoc}' | ${clipcmd} -i \n${str}\n${heredoc}`
|
||||
let result = await run(clipcmd)
|
||||
if (result.code != 0)
|
||||
throw new Error(
|
||||
|
|
Loading…
Add table
Reference in a new issue