diff --git a/Changelog.md b/Changelog.md
--- a/Changelog.md
+++ b/Changelog.md
@@ -1,3 +1,7 @@
+### 0.2.0.0
+
+- Using function *shell* to properly pass the plugin's options.
+
 ### 0.1.1.0
 
 - Using bytestrings when reading from stdin and writing to the temporary file.
diff --git a/GhcStdin.hs b/GhcStdin.hs
--- a/GhcStdin.hs
+++ b/GhcStdin.hs
@@ -27,6 +27,7 @@
 import           System.IO.Temp
 import           System.Process
 import           System.Exit
+import           Safe
 
 -- | Frontend plugin for GHC to compile source code from the standard input.
 --
@@ -66,9 +67,7 @@
 -- Internally, the plugin creates a temporary directory with a temporary source
 -- file inside it with the contents read from the standard input. Then it spawns
 -- another GHC process to compile this file with the options passed in
--- /-ffrontend-opt/. Note that the options get collected by 'words' without
--- passing them to a shell preprocessor which means that it is not possible to
--- escape spaces in their values with quotes or backslashes.
+-- /-ffrontend-opt/.
 frontendPlugin :: FrontendPlugin
 frontendPlugin = defaultFrontendPlugin { frontend = compileCodeFromStdin }
 
@@ -78,11 +77,10 @@
         withTempFile dir "ghc-stdin.hs" $ \src hsrc -> do
             contents <- B.getContents
             B.hPutStr hsrc contents >> hFlush hsrc
-            -- FIXME: wordsOfHead won't hide spaces inside quotes correctly,
-            -- but using spaces does not seem to be an often case in GHC options
-            (_, _, _, h) <- createProcess $ proc ghc $ src : wordsOfHead flags
+            (_, _, _, h) <- createProcess $
+                shell $ q ghc ++ spc (q src) ++ spc (headDef "" flags)
             r <- waitForProcess h
             unless (r == ExitSuccess) $ exitWith r
-    where wordsOfHead [] = []
-          wordsOfHead (x : _) = words x
+    where q s = let q' = '\'' in q' : s ++ pure q'
+          spc = (' ' :)
 
diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -40,7 +40,5 @@
 Internally, the plugin creates a temporary directory with a temporary source
 file inside it with the contents read from the standard input. Then it spawns
 another GHC process to compile this file with the options passed in
-*-ffrontend-opt*. Note that the options get collected by *words* without
-passing them to a shell preprocessor which means that it is not possible to
-escape spaces in their values with quotes or backslashes.
+*-ffrontend-opt*.
 
diff --git a/ghc-stdin.cabal b/ghc-stdin.cabal
--- a/ghc-stdin.cabal
+++ b/ghc-stdin.cabal
@@ -1,5 +1,5 @@
 name:                  ghc-stdin
-version:               0.1.1.1
+version:               0.2.0.0
 synopsis:              Compile source code from the standard input
 description:           A frontend plugin for GHC to compile source code from
                        the standard input.
@@ -27,7 +27,8 @@
                        ghc-paths,
                        bytestring,
                        temporary,
-                       process
+                       process,
+                       safe
 
   exposed-modules:     GhcStdin
 
