Skip to content

Commit

Permalink
Tuesday 2024-11-26 19:29:08
Browse files Browse the repository at this point in the history
  • Loading branch information
jackokring committed Nov 26, 2024
1 parent 9a5edfe commit 7141ceb
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lua/doris/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ local nv = require("doris.novaride")
nv.track(os)

---replace double quotes by escaped double quotes only
---thn escape $ and add surrounding double quotes
---then escape $ and add surrounding double quotes
---useful for escaping shell arguments for os.execute()
---@param chars string
---@return string
os.shell_quote = function(chars)
-- and then there's $ as in os $HOME etc.
local q = string.gsub(chars, "[^\\]%$", "\\$")
return '"' .. string.gsub(string.gsub(q, "\\", "\\\\"), '"', '\\"') .. '"'
local q = string.gsub(string.gsub(chars, "\\", "\\\\"), '"', '\\"')
return '"' .. string.gsub(q, "[^\\]%$", "\\$") .. '"'
end

---check if a command exists
Expand Down

0 comments on commit 7141ceb

Please sign in to comment.