[Haskell-cafe] How to get a file path to the program invoked?

Felipe Almeida Lessa felipe.lessa at gmail.com
Thu Dec 1 18:13:49 CET 2011


On Thu, Dec 1, 2011 at 2:12 PM, dokondr <dokondr at gmail.com> wrote:
> Hi,
> When my program starts it needs to know a complete path to the directory
> from which it was invoked.
> In terms of standard shell (sh) I need the Haskell function that will do
> equivalent to:
>
> #!/bin/sh
> path=$(dirname $0)
>
> How to get this path in Haskell?

If I understand you correctly, you want

  takeDirectory `fmap` getProgName

where

  import System.FilePath (takeDirectory)

Cheers,

-- 
Felipe.



More information about the Haskell-Cafe mailing list