diff options
author | Joey Hess <joey@kitenet.net> | 2010-12-31 20:33:43 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2010-12-31 20:33:43 -0400 |
commit | 5c29bb3b7c280b3e2db26dbcb38f063430f731d6 (patch) | |
tree | f996fc2565d3198f7aaebb29264bf8658fb79196 /git-annex-shell.hs | |
parent | e153a116bb45eac409a7d4b0a07c5ba10634bd36 (diff) |
git-annex-shell can now be used as a login shell
Diffstat (limited to 'git-annex-shell.hs')
-rw-r--r-- | git-annex-shell.hs | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/git-annex-shell.hs b/git-annex-shell.hs index 8783e7f60..251acf613 100644 --- a/git-annex-shell.hs +++ b/git-annex-shell.hs @@ -7,6 +7,7 @@ import System.Environment import Control.Monad (when) +import Data.List import qualified GitRepo as Git import CmdLine @@ -43,14 +44,14 @@ main' :: [String] -> IO () main' [] = failure -- skip leading -c options, passed by eg, ssh main' ("-c":p) = main' p --- Since git-annex explicitly runs git-annex-shell, we will be passed --- a redundant "git-annex-shell" parameter when we're the user's login shell. -main' ("git-annex-shell":p) = main' p -- a command can be either a builtin or something to pass to git-shell main' c@(cmd:dir:params) | elem cmd builtins = builtin cmd dir params | otherwise = external c main' c@(cmd:_) + -- Handle the case of being the user's login shell. It will be passed + -- a single string containing all the real parameters. + | isPrefixOf "git-annex-shell " cmd = main' $ drop 1 $ shellUnEscape cmd | elem cmd builtins = failure | otherwise = external c @@ -60,13 +61,20 @@ builtins = map cmdname cmds builtin :: String -> String -> [String] -> IO () builtin cmd dir params = do let gitrepo = Git.repoFromPath dir - dispatch gitrepo (cmd:params) cmds commonOptions header + dispatch gitrepo (cmd:(filterparams params)) cmds commonOptions header external :: [String] -> IO () -external l = do - ret <- boolSystem "git-shell" ("-c":l) +external params = do + ret <- boolSystem "git-shell" ("-c":(filterparams params)) when (not ret) $ error "git-shell failed" +-- Drop all args after "--". +-- These tend to be passed by rsync and not useful. +filterparams :: [String] -> [String] +filterparams [] = [] +filterparams ("--":_) = [] +filterparams (a:as) = a:filterparams as + failure :: IO () failure = error $ "bad parameters\n\n" ++ usage header cmds commonOptions |