Simon Hengel | 3 Oct 20:14 2012
Picon

Proposal: Add setEnv/unsetEnv to "base"

Hi,
setting environment variables is possible on both POSIX and Windows
systems.  Currently this functionally is missing from
System.Environment; the "unix" package provides an implementation for
POSIX systems.

I propose to add setEnv/unsetEnv to System.Environment, so that it is
easier to write applications that behave the same on POSIX and Windows
systems.

I implemented both in a way, so that they behave exactly the same on
POSIX and Windows (modulo case sensitivity on Windows).

For now I prepared a standalone implementation [1] and corresponding
tests [2].  That implementation depends on the "unix" package.  If the
proposal is accepted, I will prepare a patch against "base" that
includes the relevant code from "unix".

Discussion Period: 2 Weeks

Cheers,
Simon

[1] https://github.com/sol/setenv/blob/master/src/System/SetEnv.hs
[2] https://github.com/sol/setenv/blob/master/test/System/SetEnvSpec.hs
Simon Hengel | 18 Nov 20:43 2012
Picon

Proposal Summary: Add setEnv/unsetEnv to "base"

> I propose to add setEnv/unsetEnv to System.Environment, so that it is
> easier to write applications that behave the same on POSIX and Windows
> systems.

I finally prepared a patch for "base" [1].  Contrary to what I
originally assumed, getting it right on POSIX systems is much harder
than on Windows.

Here is the summary of the discussion:

As I understand it, Duncan Coutts, Gregory Collins, Edward A. Kmett and
Ben Millwood support the proposal.

Gregory Collins noted that

> you can get rid of unsetEnv if you make setEnv take a "Maybe String",
> which might be better.  Ultimately though, who cares what color the
> bike shed is painted :)

And I explained that

> on Windows, setEnv "FOO" "" will remove FOO from the environment.  I
> don't particularly like it, but as my stated goal was to provide the
> exact same behavior on all platforms and there is no way to work
> around this on Windows my implementation does the same thing.
>
> People who don't care for Windows support and want to set an
> environment variable to the empty string can still use "unix".
>
> So short answer: setEnv already supports removing.
(Continue reading)

Conrad Parker | 19 Nov 01:54 2012

Re: Proposal Summary: Add setEnv/unsetEnv to "base"

On 19 November 2012 03:43, Simon Hengel <sol <at> typeful.net> wrote:
>> I propose to add setEnv/unsetEnv to System.Environment, so that it is
>> easier to write applications that behave the same on POSIX and Windows
>> systems.
>
> I finally prepared a patch for "base" [1].  Contrary to what I
> originally assumed, getting it right on POSIX systems is much harder
> than on Windows.
>
> Here is the summary of the discussion:
>
> As I understand it, Duncan Coutts, Gregory Collins, Edward A. Kmett and
> Ben Millwood support the proposal.
>
> Gregory Collins noted that
>
>> you can get rid of unsetEnv if you make setEnv take a "Maybe String",
>> which might be better.  Ultimately though, who cares what color the
>> bike shed is painted :)
>
> And I explained that
>
>> on Windows, setEnv "FOO" "" will remove FOO from the environment.  I
>> don't particularly like it, but as my stated goal was to provide the
>> exact same behavior on all platforms and there is no way to work
>> around this on Windows my implementation does the same thing.
>>
>> People who don't care for Windows support and want to set an
>> environment variable to the empty string can still use "unix".
>>
(Continue reading)

Simon Hengel | 19 Nov 17:39 2012
Picon

Re: Proposal Summary: Add setEnv/unsetEnv to "base"

On Mon, Nov 19, 2012 at 08:54:11AM +0800, Conrad Parker wrote:
> On 19 November 2012 03:43, Simon Hengel <sol <at> typeful.net> wrote:
> >> I propose to add setEnv/unsetEnv to System.Environment, so that it is
> >> easier to write applications that behave the same on POSIX and Windows
> >> systems.
> >
> > I finally prepared a patch for "base" [1].  Contrary to what I
> > originally assumed, getting it right on POSIX systems is much harder
> > than on Windows.
> >
> > Here is the summary of the discussion:
> >
> > As I understand it, Duncan Coutts, Gregory Collins, Edward A. Kmett and
> > Ben Millwood support the proposal.
> >
> > Gregory Collins noted that
> >
> >> you can get rid of unsetEnv if you make setEnv take a "Maybe String",
> >> which might be better.  Ultimately though, who cares what color the
> >> bike shed is painted :)
> >
> > And I explained that
> >
> >> on Windows, setEnv "FOO" "" will remove FOO from the environment.  I
> >> don't particularly like it, but as my stated goal was to provide the
> >> exact same behavior on all platforms and there is no way to work
> >> around this on Windows my implementation does the same thing.
> >>
> >> People who don't care for Windows support and want to set an
> >> environment variable to the empty string can still use "unix".
(Continue reading)


Gmane