summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar https://www.rfc1149.net/ <Sam@web>2014-02-11 08:04:27 +0000
committerGravatar admin <admin@branchable.com>2014-02-11 08:04:27 +0000
commit025df0c3845c192f285a4182dbfe56688c63c581 (patch)
treeb2f0dbd77d2e46c5d48f6753c7e823f23b450637
parent7f273d71a94bdf1b040b26da57b8f343ddea4b67 (diff)
-rw-r--r--doc/bugs/Matching_oddity_in_SafeCommand.hs.mdwn26
1 files changed, 26 insertions, 0 deletions
diff --git a/doc/bugs/Matching_oddity_in_SafeCommand.hs.mdwn b/doc/bugs/Matching_oddity_in_SafeCommand.hs.mdwn
new file mode 100644
index 000000000..c65c8ac0b
--- /dev/null
+++ b/doc/bugs/Matching_oddity_in_SafeCommand.hs.mdwn
@@ -0,0 +1,26 @@
+In SafeCommand.hs, the code to unwrap a File looks like:
+
+[[!format haskell """
+toCommand :: [CommandParam] -> [String]
+toCommand = concatMap unwrap
+ where
+ [...]
+ -- Files that start with a non-alphanumeric that is not a path
+ -- separator are modified to avoid the command interpreting them as
+ -- options or other special constructs.
+ unwrap (File s@(h:_))
+ | isAlphaNum h || h `elem` pathseps = [s]
+ | otherwise = ["./" ++ s]
+ unwrap (File s) = [s]
+ [...]
+"""]]
+
+I am not sure I understand which case would be caught in the last clause "unwrap (File s)". Is that the empty file? Because all non-empty file names seem to have been caught earlier, at least in the "otherwise" if they do not match the condition. In this case, wouldn't it be an error to use an empty file name and wouldn't it be better to throw an exception instead of returning [[]]?
+
+I would use:
+
+[[!format haskell """
+ unwrap (File []) = throw "Empty file name in SafeCommand.toCommand"
+"""]]
+
+or something similar instead.