Advertisement
Guest User

Fragile Argument Filter

a guest
Sep 1st, 2015
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module Main where
  2.  
  3. import Data.List
  4.  
  5. import System.Environment
  6. import System.Directory
  7. import System.Process
  8.  
  9. getFirstPathArg :: [String] -> String
  10. getFirstPathArg []          =  error "No Path Found"
  11. getFirstPathArg (arg : rest)
  12.     | not $ isPrefixOf "+" arg   = arg
  13.     | otherwise             = getFirstPathArg rest
  14.  
  15. main = do
  16.     let notepadDir = "C:/Program Files (x86)/Notepad++/notepad++.exe"
  17.  
  18.     args <- getArgs
  19.     let fileName = getFirstPathArg args
  20.    
  21.     curDir <- getCurrentDirectory
  22.    
  23.     runProcess
  24.         notepadDir
  25.         [fileName]
  26.         (Just curDir)
  27.         Nothing
  28.         Nothing
  29.         Nothing
  30.         Nothing
  31.        
  32.     return ()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement