diff options
author | Fraser Tweedale <frase@frase.id.au> | 2021-01-10 17:15:38 +1000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-07-06 13:36:46 -0400 |
commit | 4b4c5e43ab40d277f18af86db049223fdf55fa59 (patch) | |
tree | 7192f2a2837409e355cf6d40b2d28c1157978473 /libraries/exceptions | |
parent | 9b1d9cbfa7a1beecc4125e35562f542b30ee4f2e (diff) | |
download | haskell-4b4c5e43ab40d277f18af86db049223fdf55fa59.tar.gz |
Implement improved "get executable path" query
System.Environment.getExecutablePath has some problems:
- Some system-specific implementations throw an exception in some
scenarios, e.g. when the executable file has been deleted
- The Linux implementation succeeds but returns an invalid FilePath
when the file has been deleted.
- The fallback implementation returns argv[0] which is not
necessarily an absolute path, and is subject to manipulation.
- The documentation does not explain any of this.
Breaking the getExecutablePath API or changing its behaviour is not
an appealing direction. So we will provide a new API.
There are two facets to the problem of querying the executable path:
1. Does the platform provide a reliable way to do it? This is
statically known.
2. If so, is there a valid answer, and what is it? This may vary,
even over the runtime of a single process.
Accordingly, the type of the new mechanism is:
Maybe (IO (Maybe FilePath))
This commit implements this mechanism, defining the query action for
FreeBSD, Linux, macOS and Windows.
Fixes: #10957
Fixes: #12377
Diffstat (limited to 'libraries/exceptions')
0 files changed, 0 insertions, 0 deletions