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/BufferedPipeReader.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/Plugins/BufferedPipeReader.hs') diff --git a/src/Plugins/BufferedPipeReader.hs b/src/Plugins/BufferedPipeReader.hs index 9a7266e..b6cad9d 100644 --- a/src/Plugins/BufferedPipeReader.hs +++ b/src/Plugins/BufferedPipeReader.hs @@ -20,6 +20,7 @@ import Control.Concurrent.STM import System.IO import System.IO.Unsafe(unsafePerformIO) +import Environment import Plugins import Signal @@ -51,7 +52,8 @@ instance Exec BufferedPipeReader where reader :: (Int, Bool, FilePath) -> TChan (Int, Bool, String) -> IO () reader p@(to, tg, fp) tc = do - openFile fp ReadWriteMode >>= hGetLineSafe >>= \dt -> + fp' <- expandEnv fp + openFile fp' ReadWriteMode >>= hGetLineSafe >>= \dt -> atomically $ writeTChan tc (to, tg, dt) reader p tc -- cgit v1.2.3