[Haskell-cafe] Parsing command lines

Khudyakov Alexey alexey.skladnoy at gmail.com
Mon May 25 11:17:42 EDT 2009


On Monday 25 of May 2009 18:57:28 Patai Gergely wrote:
> Hello all,
>
> is there a function that can safely split a command line into a FilePath
> to the executable and its parameters? I couldn't manage to find one. If
> not, what are the pitfalls in creating a cross-platform solution to this
> problem? Can I assume that the first space not within double quotes and
> not preceded by an unescaped backslash marks the end of the executable
> path, or is that too naive (or completely wrong)?
>
> Gergely

There getArgs and getProgName in System module. If you want parse this 
parameters there is System.Console.GetOpt. 

All the splitting, escaping and quotes interpretaion is done by shell. All 
what get program when starts is list of strings. Program name is actually 
arbitrary string. (At least on unices, it may work a bit differently on 
windows). 

--
  Khudyakov Alexey


More information about the Haskell-Cafe mailing list