Skip to content

Commit

Permalink
fix: escape newlines in generated vimscript (direnv#1347)
Browse files Browse the repository at this point in the history
  • Loading branch information
diniamo authored Dec 25, 2024
1 parent 20bb577 commit 29df557
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/cmd/shell_vim.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,9 @@ func (sh vim) escapeKey(str string) string {

// TODO: Make sure this escaping is valid
func (sh vim) escapeValue(str string) string {
return "'" + strings.Replace(str, "'", "''", -1) + "'"
replacer := strings.NewReplacer(
"\n", "\\n",
"'", "''",
)
return "'" + replacer.Replace(str) + "'"
}

0 comments on commit 29df557

Please sign in to comment.