on master help sign in
added posix shell escape lib
5224b21Owen Shepherd
lib/cliapp/obelisk-cliapp.cabal+1
@@ -16,6 +16,7 @@ library
16 , logging-effect
16 , logging-effect
17 , monad-loops
17 , monad-loops
18 , mtl
18 , mtl
19+ , posix-escape
19 , process
20 , process
20 , terminal-size
21 , terminal-size
21 , text
22 , text
lib/cliapp/src/Obelisk/CliApp/Process.hs+2−2
@@ -40,6 +40,7 @@ import System.IO (Handle)
40import System.IO.Streams (InputStream, handleToInputStream)
40import System.IO.Streams (InputStream, handleToInputStream)
41import qualified System.IO.Streams as Streams
41import qualified System.IO.Streams as Streams
42import System.IO.Streams.Concurrent (concurrentMerge)
42import System.IO.Streams.Concurrent (concurrentMerge)
43+import System.Posix.Escape (escape)
43import System.Process (CreateProcess, ProcessHandle, StdStream (CreatePipe), cmdspec, std_err, std_out,
44import System.Process (CreateProcess, ProcessHandle, StdStream (CreatePipe), cmdspec, std_err, std_out,
44 waitForProcess)
45 waitForProcess)
45import qualified System.Process as Process
46import qualified System.Process as Process
@@ -182,5 +183,4 @@ reconstructCommand :: Process.CmdSpec -> Text
182reconstructCommand (Process.ShellCommand str) = T.pack str
183reconstructCommand (Process.ShellCommand str) = T.pack str
183reconstructCommand (Process.RawCommand c as) = processToShellString c as
184reconstructCommand (Process.RawCommand c as) = processToShellString c as
184 where
185 where
185− processToShellString cmd args = T.unwords $ map quoteAndEscape (cmd : args)
186+ processToShellString cmd args = T.pack $ unwords $ map escape (cmd : args)
186− quoteAndEscape x = "'" <> T.replace "'" "'\''" (T.pack x) <> "'"
lib/command/obelisk-command.cabal+1
@@ -39,6 +39,7 @@ library
39 , optparse-applicative
39 , optparse-applicative
40 , placeholders
40 , placeholders
41 , process
41 , process
42+ , posix-escape
42 , temporary
43 , temporary
43 , terminal-size
44 , terminal-size
44 , text
45 , text
lib/command/src/Obelisk/Command.hs+2−1
@@ -26,6 +26,7 @@ import System.Environment
26import System.FilePath
26import System.FilePath
27import qualified System.Info
27import qualified System.Info
28import System.IO (hIsTerminalDevice, stdout)
28import System.IO (hIsTerminalDevice, stdout)
29+import System.Posix.Escape (escapeMany)
29import System.Posix.Process (executeFile)
30import System.Posix.Process (executeFile)
30
31
31import Obelisk.App
32import Obelisk.App
@@ -105,7 +106,7 @@ data ObInternal
105
106
106inNixShell' :: MonadObelisk m => StaticPtr (ObeliskT IO ()) -> m ()
107inNixShell' :: MonadObelisk m => StaticPtr (ObeliskT IO ()) -> m ()
107inNixShell' p = withProjectRoot "." $ \root -> do
108inNixShell' p = withProjectRoot "." $ \root -> do
108− cmd <- liftIO $ unwords <$> mkCmd -- TODO: shell escape instead of unwords
109+ cmd <- liftIO $ escapeMany <$> mkCmd
109 projectShell root True "ghc" (Just cmd)
110 projectShell root True "ghc" (Just cmd)
110 where
111 where
111 mkCmd = do
112 mkCmd = do
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