Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix augment path #237

Merged

Conversation

hasufell
Copy link
Contributor

@hasufell hasufell commented Aug 9, 2021

On windows, env vars are generally case-insensitive.
Due to 'type EnvVars = Map Text Text' augmentPathMap
assumes full uppercase "PATH" variable, which may lead
to surprising behavior if the current map
has a variable such as "Path".

This patch folds over the map and inserts any path
key as "PATH" on windows. That also means: if there
are multiple, the "last" one wins. There generally
isn't a sane solution if the input map already
has multiple path keys (how should they be merged,
which order?).

Fixes #234

rio/src/RIO/Process.hs Outdated Show resolved Hide resolved
@hasufell hasufell force-pushed the jospald/fix-augment-path branch 2 times, most recently from b2d676a to 3cd36c7 Compare August 9, 2021 14:29
On windows, env vars are generally case-insensitive.
Due to 'type EnvVars = Map Text Text' augmentPathMap
assumes full uppercase "PATH" variable, which may lead
to surprising behavior if the current map
has a variable such as "Path".

This patch folds over the map and inserts any path
key as "PATH" on windows. That also means: if there
are multiple, the "last" one wins. There generally
isn't a sane solution if the input map already
has multiple path keys (how should they be merged,
which order?).

Fixes commercialhaskell#234
-- Default value for PATHTEXT on Windows versions after Windows XP. (The
-- documentation of the default at
-- https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/start
-- is incomplete.)
defaultPATHEXT = ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC"


-- Fix case insensitivity of the PATH environment variable on Windows,
-- by forcing all keys full uppercase.
normalizePathEnv :: EnvVars -> EnvVars
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not entirely sure if we need an inline pragma here.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's reasonable as-is.

Copy link
Collaborator

@snoyberg snoyberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I'll merge/release once CI passes. Thanks!

-- Default value for PATHTEXT on Windows versions after Windows XP. (The
-- documentation of the default at
-- https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/start
-- is incomplete.)
defaultPATHEXT = ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC"


-- Fix case insensitivity of the PATH environment variable on Windows,
-- by forcing all keys full uppercase.
normalizePathEnv :: EnvVars -> EnvVars
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's reasonable as-is.

@snoyberg snoyberg merged commit e724637 into commercialhaskell:master Aug 9, 2021
@snoyberg
Copy link
Collaborator

snoyberg commented Aug 9, 2021

Released to Hackage, thanks!

@snoyberg
Copy link
Collaborator

snoyberg commented Aug 9, 2021

I'll open a PR against Stack to use this newer version, unless you'd like to open that PR instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

augmentPathMap assumes uppercase PATH on windows
2 participants