aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2017-06-12 02:12:51 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2017-06-12 02:12:51 +0300
commit5c3b840df3897c216dafeb5f63a39ee12f63a804 (patch)
tree14f1b317f39c895a14fb4660e137d24a06f77526
parentWindowsEnv: {VarName,VarValue} -> {Name,Value} (diff)
downloadwindows-env-5c3b840df3897c216dafeb5f63a39ee12f63a804.tar.gz
windows-env-5c3b840df3897c216dafeb5f63a39ee12f63a804.zip
setenv: detect expandable values
Diffstat (limited to '')
-rw-r--r--app/SetEnv.hs18
1 files changed, 12 insertions, 6 deletions
diff --git a/app/SetEnv.hs b/app/SetEnv.hs
index d590f64..258bc2e 100644
--- a/app/SetEnv.hs
+++ b/app/SetEnv.hs
@@ -55,7 +55,7 @@ setEnv :: Options -> IO ()
setEnv options = runExceptT doSetEnv >>= either ioError return
where
varName = optName options
- varValue = WindowsEnv.Value False $ optValue options
+ varValue = optValue options
forAllUsers = optGlobal options
profile
@@ -63,10 +63,16 @@ setEnv options = runExceptT doSetEnv >>= either ioError return
| otherwise = WindowsEnv.CurrentUser
skipPrompt = optYes options
- promptAnd
- | skipPrompt = withoutPrompt
- | otherwise = withPrompt $ newMessage profile varName varValue
- engrave = WindowsEnv.engrave profile varName varValue
+ doSetEnv = do
+ expanded <- WindowsEnv.expand varValue
+ let expandable = expanded == varValue
+ let newValue = WindowsEnv.Value expandable varValue
+ promptAndEngrave newValue
- doSetEnv = void $ promptAnd engrave
+ promptAndEngrave newValue = do
+ let promptAnd = if skipPrompt
+ then withoutPrompt
+ else withPrompt $ newMessage profile varName newValue
+ let engrave = WindowsEnv.engrave profile varName newValue
+ void $ promptAnd engrave