executable-path-0.0.3.1: Finding out the full path of the executable.

Safe Haskell | None
Language | Haskell98

System.Environment.Executable

Description

The documentation of "System.Environment.getProgName" says that

"However, this is hard-to-impossible to implement on some non-Unix OSes, so instead, for maximum portability, we just return the leafname of the program as invoked. Even then there are some differences between platforms: on Windows, for example, a program invoked as foo is probably really FOO.EXE, and that is what "getProgName" will return."

This library tries to fix this issue. It also provides some platform-specific functions (most notably getting the path of the application bundle on OSX). Supported operating systems:

- Win32 (tested on Windows 7)
- Mac OS X
- Linux
- FreeBSD (tested on FreeBSD 6.4)
- *BSD (with procfs mounted, plus fallback for certain shells; untested)
- Solaris (untested, and probably works on Solaris 10 only)

Synopsis

- getExecutablePath :: IO FilePath
- splitExecutablePath :: IO (FilePath, FilePath)
- data ScriptPath
  - = Executable FilePath
  - | RunGHC FilePath
  - | Interactive
- getScriptPath :: IO ScriptPath

# Documentation

getExecutablePath :: IO FilePath Source #

splitExecutablePath :: IO (FilePath, FilePath) Source #

data ScriptPath Source #

Constructors

Executable FilePath | it was (probably) a proper compiled executable
RunGHC FilePath | it was a script run by runghc/runhaskell
Interactive | we are in GHCi

#### Instances

Instances details

Show ScriptPath Source # |
Instance details Defined in System.Environment.Executable Methods showsPrec :: Int -> ScriptPath -> ShowS Source # show :: ScriptPath -> String Source # showList :: [ScriptPath] -> ShowS Source #

getScriptPath :: IO ScriptPath Source #

An experimental hack which tries to figure out if the program was run with `runghc` or `runhaskell` or `ghci`, and then tries to find out the directory of the source (or object file).

GHC only.