Skip to content

Commit dfb96f2

Browse files
committed
Add System.Process.Environment(.OsString) modules
1 parent 1d5e891 commit dfb96f2

File tree

4 files changed

+71
-3
lines changed

4 files changed

+71
-3
lines changed

System/Process/Environment.hs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-- | Miscellaneous information about the system environment.
2+
--
3+
-- @since X.Y.Z
4+
module System.Process.Environment (
5+
Env.getArgs,
6+
Env.getEnv,
7+
Env.getEnvironment,
8+
) where
9+
10+
import qualified System.Environment as Env
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{-# LANGUAGE CPP #-}
2+
{-# LANGUAGE PackageImports #-}
3+
4+
-- | Miscellaneous information about the system environment, for 'OsString'.
5+
--
6+
-- @since X.Y.Z
7+
module System.Process.Environment.OsString (
8+
getArgs,
9+
getEnv,
10+
getEnvironment,
11+
) where
12+
13+
import Data.Coerce (coerce)
14+
#if MIN_VERSION_filepath(1, 5, 0)
15+
import "os-string" System.OsString.Internal.Types (OsString(OsString))
16+
#else
17+
import "filepath" System.OsString.Internal.Types (OsString(OsString))
18+
#endif
19+
#if defined(mingw32_HOST_OS)
20+
import qualified System.Win32.WindowsString.Console as Platform
21+
#else
22+
import qualified System.Posix.Env.PosixString as Platform
23+
#endif
24+
25+
-- | 'System.Environment.getArgs' for 'OsString'.
26+
--
27+
-- @since X.Y.Z
28+
getArgs :: IO [OsString]
29+
getArgs = coerce Platform.getArgs
30+
31+
-- | 'System.Environment.getEnv' for 'OsString'.
32+
--
33+
-- @since X.Y.Z
34+
getEnv :: OsString -> IO (Maybe OsString)
35+
getEnv = coerce Platform.getEnv
36+
37+
-- | 'System.Environment.getEnvironment' for 'OsString'.
38+
--
39+
-- @since X.Y.Z
40+
getEnvironment :: IO [(OsString, OsString)]
41+
getEnvironment = coerce Platform.getEnvironment

changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog for [`process` package](http://hackage.haskell.org/package/process)
22

3+
## X.Y.Z
4+
5+
* Add `System.Process.Env` and `System.Process.Env.OsString`. Bumps
6+
`filepath >= 1.4.100.0`.
7+
38
## 1.6.25.0 *September 2024*
49

510
* Fix build with Javascript backend ([#327](https://github.com/haskell/process/issues/327))

process.cabal

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ source-repository head
4141
type: git
4242
location: https://github.com/haskell/process.git
4343

44+
flag os-string
45+
description: Use the new os-string package
46+
default: False
47+
manual: False
48+
4449
library
4550
default-language: Haskell2010
4651
other-extensions:
@@ -56,19 +61,21 @@ library
5661
System.Process
5762
System.Process.CommunicationHandle
5863
System.Process.CommunicationHandle.Internal
64+
System.Process.Environment
65+
System.Process.Environment.OsString
5966
System.Process.Internals
6067
other-modules: System.Process.Common
6168
if os(windows)
6269
c-sources:
6370
cbits/win32/runProcess.c
6471
other-modules: System.Process.Windows
65-
build-depends: Win32 >=2.4 && < 2.15
72+
build-depends: Win32 >= 2.14.1.0 && < 2.15
6673
-- ole32 and rpcrt4 are needed to create GUIDs for unique named pipes
6774
-- for process.
6875
extra-libraries: kernel32, ole32, rpcrt4
6976
cpp-options: -DWINDOWS
7077
else
71-
build-depends: unix >= 2.5 && < 2.9
78+
build-depends: unix >= 2.8.0.0 && < 2.9
7279
if arch(javascript)
7380
js-sources:
7481
jsbits/process.js
@@ -90,5 +97,10 @@ library
9097

9198
build-depends: base >= 4.10 && < 4.22,
9299
directory >= 1.1 && < 1.4,
93-
filepath >= 1.2 && < 1.6,
94100
deepseq >= 1.1 && < 1.6
101+
102+
if flag(os-string)
103+
build-depends: filepath >= 1.5.0.0 && < 1.6,
104+
os-string >= 2.0.0 && < 2.1
105+
else
106+
build-depends: filepath >= 1.4.100.0 && < 1.5.0.0

0 commit comments

Comments
 (0)