aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Process/Shell.hs14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/Process/Shell.hs b/src/Process/Shell.hs
index 2d254ad..10b85b5 100644
--- a/src/Process/Shell.hs
+++ b/src/Process/Shell.hs
@@ -144,12 +144,8 @@ sh = QuasiQuoter quoteExp undefined undefined undefined
Lit <$> takeWhile1P Nothing ((&&) <$> (/= '#') <*> (/= '\''))
]
- makeExp :: [Expr] -> Q Exp
- makeExp exprs = do
- appE [|sh_|] $ flip (foldM (flip go)) exprs =<< [|""|]
-
- go (Lit s) = appE [|flip (++) s|] . pure
- go (Var q exp) =
- appE
- (appE [|flip (++)|] (appE [|if q then squote else dquote|] exp))
- . pure
+ makeExp exprs =
+ [|sh_ $(foldr (\a b -> [|$a ++ $b|]) [|""|] (map toExp exprs))|]
+
+ toExp (Lit s) = [|s|]
+ toExp (Var q exp) = [|(if q then squote else dquote) $exp|]