fix the word completion in the shell

This commit is contained in:
krasimir
2008-10-22 11:27:01 +00:00
parent bb007215ab
commit 9ba3b739df

View File

@@ -272,10 +272,14 @@ wc_type = cmd_name
| otherwise = cmd x cs | otherwise = cmd x cs
option x y [] = ret CmplOpt x y 1 option x y [] = ret CmplOpt x y 1
option x y ('=':cs) = optValue x y cs
option x y (c :cs) option x y (c :cs)
| isIdent c = option x y cs | isIdent c = option x y cs
| otherwise = cmd x cs | otherwise = cmd x cs
optValue x y ('"':cs) = str x y cs
optValue x y cs = cmd x cs
ident x y [] = ret CmplIdent x y 0 ident x y [] = ret CmplIdent x y 0
ident x y (c:cs) ident x y (c:cs)
| isIdent c = ident x y cs | isIdent c = ident x y cs
@@ -289,7 +293,7 @@ wc_type = cmd_name
ret f x y d = f cmd y ret f x y d = f cmd y
where where
x1 = take (length x - length y - d) x x1 = take (length x - length y - d) x
x2 = takeWhile (\c -> isIdent c || isSpace c || c == '-' || c == '=') x1 x2 = takeWhile (\c -> isIdent c || isSpace c || c == '-' || c == '=' || c == '"') x1
cmd = case [x | (x,cs) <- RP.readP_to_S pCommand x2, all isSpace cs] of cmd = case [x | (x,cs) <- RP.readP_to_S pCommand x2, all isSpace cs] of
[x] -> Just x [x] -> Just x