on master help sign in
added posix shell escape lib
commit3c594dc05cc746138c11eab2e43c1eb488a446b3 authorOwen Shepherd <414owen@gmail.com> dateWed 18 Dec 2019, 14:53 (7 years ago) parent662777e
5 files changed+6−2
lib/cliapp/obelisk-cliapp.cabal+1 lib/cliapp/src/Obelisk/CliApp/Process.hs+2−2 result-2+1 result-3+1 result-4+1
lib/cliapp/obelisk-cliapp.cabal+1
@@ -18,6 +18,7 @@ library
1818 , logging-effect
1919 , monad-loops
2020 , mtl
21+ , posix-escape
2122 , process
2223 , terminal-size
2324 , text
lib/cliapp/src/Obelisk/CliApp/Process.hs+2−2
@@ -52,6 +52,7 @@ import System.IO (Handle)
5252import System.IO.Streams (InputStream, handleToInputStream)
5353import qualified System.IO.Streams as Streams
5454import System.IO.Streams.Concurrent (concurrentMerge)
55+import System.Posix.Escape (escape)
5556import System.Process (CreateProcess, ProcessHandle, StdStream (CreatePipe), std_err, std_out)
5657import qualified System.Process as Process
5758import qualified Data.Aeson as Aeson
@@ -246,8 +247,7 @@ reconstructCommand p = case p of
246247 Process.ShellCommand str -> T.pack str
247248 Process.RawCommand c as -> processToShellString c as
248249 where
249− processToShellString cmd args = T.unwords $ map quoteAndEscape (cmd : args)
250− quoteAndEscape x = "'" <> T.replace "'" "'\''" (T.pack x) <> "'"
250+ processToShellString cmd args = T.pack $ unwords $ map escape (cmd : args)
251251
252252reconstructProcSpec :: ProcessSpec -> Text
253253reconstructProcSpec = reconstructCommand . Process.cmdspec . _processSpec_createProcess
result-2new file+1
@@ -0,0 +1 @@
1+/nix/store/dm824gcp9v1lpym0fvj9waric653954h-selftest
result-3new file+1
@@ -0,0 +1 @@
1+/nix/store/4d5y7m7j4ljgza99hwfnrwxaa5ll8gik-obelisk-shell
result-4new file+1
@@ -0,0 +1 @@
1+/nix/store/9xix8yxpsasrg5ph7xgm7wyi8sykfhaf-skeleton