From 5c3b840df3897c216dafeb5f63a39ee12f63a804 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Mon, 12 Jun 2017 02:12:51 +0300 Subject: setenv: detect expandable values --- app/SetEnv.hs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'app') 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 -- cgit v1.2.3