Commits

nakamura committed 77771fe

escape log file name in udon tail/less subcommand

  • Participants
  • Parent commits 3524f08

Comments (0)

Files changed (3)

 commandWithCommand :: String -> [String] -> ClientCommand
 commandWithCommand cmd args = do
     logd <- asks logDir
-    let logf  = logd </> dn ++ ".log"
+    let logf  = logd </> (escapeFName $ dn ++ ".log")
         dn    = last args
         args' = init args ++ [logf]
     io $ executeFile cmd True args' Nothing
 
 getBinPath :: FilePath -> IO FilePath
 getBinPath f = getBinDir >>= return . (</> f)
+
+escapedDName :: Daemon -> String
+escapedDName = escapeFName . dName
+
+escapeFName :: String -> String
+escapeFName = escapeSlash . init . tail . show
+
+escapeSlash :: String -> String
+escapeSlash      []  = []
+escapeSlash ('/':cs) = '\\':'0':'4':'7' : escapeSlash cs
+escapeSlash   (c:cs) = c : escapeSlash cs
 
 unblkSig :: Signal -> IO ()
 unblkSig sig = unblockSignals $ addSignal sig emptySignalSet
-
-escapedDName :: Daemon -> String
-escapedDName = escapeFName . dName
-
-escapeFName :: String -> String
-escapeFName = escapeSlash . init . tail . show
-
-escapeSlash :: String -> String
-escapeSlash      []  = []
-escapeSlash ('/':cs) = '\\':'0':'4':'7' : escapeSlash cs
-escapeSlash   (c:cs) = c : escapeSlash cs