summaryrefslogtreecommitdiff
path: root/src/Parser/Shell.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2025-10-04 21:45:02 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2025-10-05 21:24:13 +0200
commit6ee42f58d7293d810a5406d06020e1fdc9bcdaf0 (patch)
treecc23366a9d79c7b1dffb8599f103a5472bb80727 /src/Parser/Shell.hs
parent11e04cd229c132ad7d79cbfd8319fb5a3d5f3cbb (diff)
Redirection in shell scriptsHEADmaster
Changelog: Implemented input/output redirection in shell scripts
Diffstat (limited to 'src/Parser/Shell.hs')
-rw-r--r--src/Parser/Shell.hs22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/Parser/Shell.hs b/src/Parser/Shell.hs
index ffc8cf1..b575842 100644
--- a/src/Parser/Shell.hs
+++ b/src/Parser/Shell.hs
@@ -71,9 +71,29 @@ parseTextArgument = lexeme $ fmap (App AnnNone (Pure T.concat) <$> foldr (liftA2
[ char ' ' >> return " "
]
+parseRedirection :: TestParser (Expr ShellArgument)
+parseRedirection = choice
+ [ do
+ osymbol "<"
+ fmap ShellRedirectStdin <$> parseTextArgument
+ , do
+ osymbol ">"
+ fmap (ShellRedirectStdout False) <$> parseTextArgument
+ , do
+ osymbol ">>"
+ fmap (ShellRedirectStdout True) <$> parseTextArgument
+ , do
+ osymbol "2>"
+ fmap (ShellRedirectStderr False) <$> parseTextArgument
+ , do
+ osymbol "2>>"
+ fmap (ShellRedirectStderr True) <$> parseTextArgument
+ ]
+
parseArgument :: TestParser (Expr ShellArgument)
parseArgument = choice
- [ fmap ShellArgument <$> parseTextArgument
+ [ parseRedirection
+ , fmap ShellArgument <$> parseTextArgument
]
parseArguments :: TestParser (Expr [ ShellArgument ])