aboutsummaryrefslogtreecommitdiff
path: root/CmdLine/GitAnnexShell/Checks.hs
diff options
context:
space:
mode:
Diffstat (limited to 'CmdLine/GitAnnexShell/Checks.hs')
-rw-r--r--CmdLine/GitAnnexShell/Checks.hs23
1 files changed, 17 insertions, 6 deletions
diff --git a/CmdLine/GitAnnexShell/Checks.hs b/CmdLine/GitAnnexShell/Checks.hs
index fcbf14b24..3409884c0 100644
--- a/CmdLine/GitAnnexShell/Checks.hs
+++ b/CmdLine/GitAnnexShell/Checks.hs
@@ -14,17 +14,28 @@ import Annex.Init
import Utility.UserInfo
import Utility.Env
+limitedEnv :: String
+limitedEnv = "GIT_ANNEX_SHELL_LIMITED"
+
checkNotLimited :: IO ()
-checkNotLimited = checkEnv "GIT_ANNEX_SHELL_LIMITED"
+checkNotLimited = checkEnv limitedEnv
+
+readOnlyEnv :: String
+readOnlyEnv = "GIT_ANNEX_SHELL_READONLY"
checkNotReadOnly :: IO ()
-checkNotReadOnly = checkEnv "GIT_ANNEX_SHELL_READONLY"
+checkNotReadOnly = checkEnv readOnlyEnv
checkEnv :: String -> IO ()
-checkEnv var = getEnv var >>= \case
- Nothing -> noop
- Just "" -> noop
- Just _ -> giveup $ "Action blocked by " ++ var
+checkEnv var = checkEnvSet var >>= \case
+ False -> noop
+ True -> giveup $ "Action blocked by " ++ var
+
+checkEnvSet :: String -> IO Bool
+checkEnvSet var = getEnv var >>= return . \case
+ Nothing -> False
+ Just "" -> False
+ Just _ -> True
checkDirectory :: Maybe FilePath -> IO ()
checkDirectory mdir = do