diff options
| author | Roman Smrž <roman.smrz@seznam.cz> | 2026-09-04 19:25:09 +0200 |
|---|---|---|
| committer | Roman Smrž <roman.smrz@seznam.cz> | 2026-09-05 21:41:39 +0200 |
| commit | a9439b66ad8f7a8f4ba079a47ecfe1e76c2abc4b (patch) | |
| tree | 7ef225d63462349b8f5708cdceecc9010734e60a /src/Script | |
| parent | c2c89cf5308ea5c490a4fe150cffc72ed09c4c1c (diff) | |
Expression expansion for shell arguments
Changelog: Lists can now be dollar-expanded in the shell interpreter to provide list of shell command arguments.
Diffstat (limited to 'src/Script')
| -rw-r--r-- | src/Script/Shell.hs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/Script/Shell.hs b/src/Script/Shell.hs index 3e98e66..e7c8542 100644 --- a/src/Script/Shell.hs +++ b/src/Script/Shell.hs @@ -15,8 +15,10 @@ import Control.Monad.IO.Class import Control.Monad.Reader import Data.Maybe +import Data.Scientific import Data.Text (Text) import Data.Text qualified as T +import Data.Typeable import Foreign.C.Types import Foreign.Ptr @@ -67,6 +69,7 @@ data ShellCommand = ShellCommand } newtype ShellArguments = ShellArguments { fromShellArguments :: [ ShellArgument ] } + deriving (Semigroup, Monoid) data ShellArgument = ShellArgument Text @@ -97,10 +100,25 @@ instance ExprType ShellArguments where textExprType _ = T.pack "ShellArguments" textExprValue _ = "<shell-arguments>" + exprExpansionConvFrom = listToMaybe $ catMaybes + [ cast (ShellArguments . (: []) . ShellArgument) + , cast (ShellArguments . (: []) . ShellArgument . T.pack . show @Integer) + , cast (ShellArguments . (: []) . ShellArgument . T.pack . show @Scientific) + , cast (ShellArguments . map ShellArgument) + , cast (ShellArguments . map (ShellArgument . T.pack . show @Integer)) + , cast (ShellArguments . map (ShellArgument . T.pack . show @Scientific)) + ] + instance ExprType ShellArgument where textExprType _ = T.pack "ShellArgument" textExprValue _ = "<shell-argument>" + exprExpansionConvFrom = listToMaybe $ catMaybes + [ cast (ShellArgument) + , cast (ShellArgument . T.pack . show @Integer) + , cast (ShellArgument . T.pack . show @Scientific) + ] + data ShellExecInfo = ShellExecInfo { seiNode :: Node |