From a93755b2d1e9efbd63723f5302ca7c8f43521aa8 Mon Sep 17 00:00:00 2001 From: Will Song Date: Sat, 16 Jul 2016 16:15:33 -0500 Subject: Add expandEnv function and use it in PipeReader family of monitors expandEnv takes a string and expands the environment variables it can find. variable substringing (e.g. ${VAR:1} to lop off the first character) is not supported, but $VAR and ${VAR} formats are, with the former being delimited by punctuation, but not underscores. --- src/Plugins/PipeReader.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/Plugins/PipeReader.hs') diff --git a/src/Plugins/PipeReader.hs b/src/Plugins/PipeReader.hs index c3e491a..653a72d 100644 --- a/src/Plugins/PipeReader.hs +++ b/src/Plugins/PipeReader.hs @@ -16,6 +16,7 @@ module Plugins.PipeReader where import System.IO import Plugins +import Environment import System.Posix.Files import Control.Concurrent(threadDelay) import Control.Exception @@ -27,7 +28,7 @@ data PipeReader = PipeReader String String instance Exec PipeReader where alias (PipeReader _ a) = a start (PipeReader p _) cb = do - let (def, pipe) = split ':' p + (def, pipe) <- split ':' <$> expandEnv p unless (null def) (cb def) checkPipe pipe h <- openFile pipe ReadWriteMode -- cgit v1.2.3