summaryrefslogtreecommitdiff
path: root/Utility/RsyncFile.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-11-18 12:53:48 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-11-18 12:53:48 -0400
commit1326bb863516b5e7efbfd9fba2754a3fe7289315 (patch)
treeadb7e8106f1420c1ccee7eae30beb2667e060f81 /Utility/RsyncFile.hs
parented55a750d5255ac07bcd04adf4365a3255b3f605 (diff)
Avoid excessive escaping for rsync special remotes that are not accessed over ssh.
This is actually tricky, 45bbf210a1210172c7c7b87879ed74f7c8ccbdba added the escaping because it's needed for rsync that does go over ssh. So I had to detect whether the remote's rsync url will use ssh or not, and vary the escaping.
Diffstat (limited to 'Utility/RsyncFile.hs')
-rw-r--r--Utility/RsyncFile.hs16
1 files changed, 16 insertions, 0 deletions
diff --git a/Utility/RsyncFile.hs b/Utility/RsyncFile.hs
index c5006a30f..a691d0a0e 100644
--- a/Utility/RsyncFile.hs
+++ b/Utility/RsyncFile.hs
@@ -8,6 +8,7 @@
module Utility.RsyncFile where
import Data.String.Utils
+import Data.List
import Utility.SafeCommand
@@ -48,3 +49,18 @@ rsync = boolSystem "rsync"
rsyncExec :: [CommandParam] -> IO ()
rsyncExec params = executeFile "rsync" True (toCommand params) Nothing
+
+{- Checks if an rsync url involves the remote shell (ssh or rsh).
+ - Use of such urls with rsync or rsyncExec requires additional shell
+ - escaping. -}
+rsyncUrlIsShell :: String -> Bool
+rsyncUrlIsShell s
+ | "rsync://" `isPrefixOf` s = False
+ | otherwise = go s
+ where
+ -- host:dir is rsync protocol, while host:dir is ssh/rsh
+ go [] = False
+ go (c:cs)
+ | c == '/' = False -- got to directory with no colon
+ | c == ':' = not $ ":" `isPrefixOf` cs
+ | otherwise = go cs