summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-02-13 14:30:04 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-02-13 14:30:04 -0400
commit86a2e79338c13108e100859a942883690ad286f3 (patch)
tree375323fc282638ae62b8b8a0b8834b6dbdf92d18
parent9aadec552b0590fbed10ed9e1d74540bbaf5fb7f (diff)
deal with Android's nonstandard shell location
This is so gratutious and pointless. It's a shame that everything we learned about Unix portability and the importance of standards has been thrown out the window by these guys.
-rw-r--r--Assistant/Install.hs3
-rw-r--r--Assistant/Ssh.hs3
-rw-r--r--Assistant/XMPP/Git.hs3
-rw-r--r--Init.hs10
-rw-r--r--Utility/Shell.hs20
5 files changed, 32 insertions, 7 deletions
diff --git a/Assistant/Install.hs b/Assistant/Install.hs
index 989843e90..0db021ef7 100644
--- a/Assistant/Install.hs
+++ b/Assistant/Install.hs
@@ -14,6 +14,7 @@ import Assistant.Install.AutoStart
import Assistant.Ssh
import Locations.UserConfig
import Utility.FileMode
+import Utility.Shell
#ifdef darwin_HOST_OS
import Utility.OSX
@@ -58,7 +59,7 @@ ensureInstalled = go =<< standaloneAppBase
sshdir <- sshDir
let shim = sshdir </> "git-annex-shell"
let content = unlines
- [ "#!/bin/sh"
+ [ shebang
, "set -e"
, "exec", base </> "runshell" ++
" git-annex-shell -c \"$SSH_ORIGINAL_COMMAND\""
diff --git a/Assistant/Ssh.hs b/Assistant/Ssh.hs
index 15c97ab53..753babad4 100644
--- a/Assistant/Ssh.hs
+++ b/Assistant/Ssh.hs
@@ -10,6 +10,7 @@ module Assistant.Ssh where
import Common.Annex
import Utility.TempFile
import Utility.UserInfo
+import Utility.Shell
import Git.Remote
import Data.Text (Text)
@@ -155,7 +156,7 @@ addAuthorizedKeysCommand rsynconly dir pubkey = join "&&"
echoval v = "echo " ++ shellEscape v
wrapper = "~/.ssh/git-annex-shell"
script =
- [ "#!/bin/sh"
+ [ shebang
, "set -e"
, "exec git-annex-shell -c \"$SSH_ORIGINAL_COMMAND\""
]
diff --git a/Assistant/XMPP/Git.hs b/Assistant/XMPP/Git.hs
index d3c8343c2..8dba309a8 100644
--- a/Assistant/XMPP/Git.hs
+++ b/Assistant/XMPP/Git.hs
@@ -25,6 +25,7 @@ import qualified Git.Branch
import Locations.UserConfig
import qualified Types.Remote as Remote
import Utility.FileMode
+import Utility.Shell
import Network.Protocol.XMPP
import qualified Data.Text as T
@@ -141,7 +142,7 @@ xmppPush cid gitpush = runPush SendPack cid handleDeferred $ do
let wrapper = tmpdir </> "git-remote-xmpp"
program <- readProgramFile
writeFile wrapper $ unlines
- [ "#!/bin/sh"
+ [ shebang
, "exec " ++ program ++ " xmppgit"
]
modifyFileMode wrapper $ addModes executeModes
diff --git a/Init.hs b/Init.hs
index 822247179..a6f4fa935 100644
--- a/Init.hs
+++ b/Init.hs
@@ -21,6 +21,7 @@ import Logs.UUID
import Annex.Version
import Annex.UUID
import Utility.UserInfo
+import Utility.Shell
genDescription :: Maybe String -> Annex String
genDescription (Just d) = return d
@@ -92,7 +93,8 @@ preCommitHook :: Annex FilePath
preCommitHook = (</>) <$> fromRepo Git.localGitDir <*> pure "hooks/pre-commit"
preCommitScript :: String
-preCommitScript =
- "#!/bin/sh\n" ++
- "# automatically configured by git-annex\n" ++
- "git annex pre-commit .\n"
+preCommitScript = unlines
+ [ shebang
+ , "# automatically configured by git-annex"
+ , "git annex pre-commit ."
+ ]
diff --git a/Utility/Shell.hs b/Utility/Shell.hs
new file mode 100644
index 000000000..fecafe1a8
--- /dev/null
+++ b/Utility/Shell.hs
@@ -0,0 +1,20 @@
+{- /bin/sh handling
+ -
+ - Copyright 2013 Joey Hess <joey@kitenet.net>
+ -
+ - Licensed under the GNU GPL version 3 or higher.
+ -}
+
+{-# LANGUAGE CPP #-}
+
+module Utility.Shell where
+
+shellPath :: FilePath
+#ifndef WITH_ANDROID
+shellPath = "/bin/sh"
+#else
+shellPath = "/system/bin/sh"
+#endif
+
+shebang :: String
+shebang = "#!" ++ shellPath