From 51663eab50cbc51a5786c0d55f21de62e9b15c0a Mon Sep 17 00:00:00 2001 From: Fabian Kirchner Date: Fri, 13 Oct 2023 22:20:18 +0200 Subject: extract quote to Process and fix quoting quotes --- app/Process.hs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'app/Process.hs') diff --git a/app/Process.hs b/app/Process.hs index 39132d4..ecc9cd3 100644 --- a/app/Process.hs +++ b/app/Process.hs @@ -23,3 +23,10 @@ sh_ proc = do if exitCode == ExitSuccess then pure () else throwIO $ ProcessException (show proc) exitCode err + +quote :: String -> String +quote s = "'" ++ escape s ++ "'" + where + escape [] = [] + escape ('\'' : cs) = '\'' : '\\' : '\'' : '\'' : escape cs + escape (c : cs) = c : escape cs -- cgit v1.2.3