| Copyright | (c) Harley Eades 2026 |
|---|---|
| Maintainer | harley.eades@gmail.com |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Configuration.Cfv.Shell
Description
This is the API for accessing the users shell. All commands are ran in the login
shell with access to the PATH environment variable, but the shell's rc-file is
not executed by default, and so aliases are not useable. If you need access to
your rc-file, then define a custom ShellConfig for your project.
Synopsis
- data CommandError = CommandError {}
- data CommandProblem
- data ShellConfig = ShellConfig {
- shellProgram :: Maybe FilePath
- shellFlags :: [String]
- evalValue :: ShellConfig -> Text -> IO (Either CommandError [Char])
- defaultShellConfig :: ShellConfig
- describeProblem :: CommandProblem -> Text
Documentation
data CommandError Source #
A backtick command that could not produce a value.
For a Configuration.Cfv.AST.Secret variable anything that could contain or reveal the secret is
withheld: the command text (which may embed it) and the details of the
command's output (see CommandProblem).
Constructors
| CommandError | |
Fields | |
Instances
| Show CommandError Source # | |
Defined in Configuration.Cfv.Shell Methods showsPrec :: Int -> CommandError -> ShowS # show :: CommandError -> String # showList :: [CommandError] -> ShowS # | |
| Eq CommandError Source # | |
Defined in Configuration.Cfv.Shell | |
data CommandProblem Source #
Errors produced by running a command on the shell.
Constructors
| NoShell | No shell configured and |
| ShellLaunchFailed FilePath IOException | The shell could not be started (not found, not executable, ...). |
| NonZeroExit Int Text | The command exited with this status (negative: killed by that signal)
and this standard error output, trimmed. The output is |
| OutputNotUtf8 UnicodeException | The command's standard output is not valid UTF-8. The exception names
the offending byte, so it is |
Instances
| Show CommandProblem Source # | |
Defined in Configuration.Cfv.Shell Methods showsPrec :: Int -> CommandProblem -> ShowS # show :: CommandProblem -> String # showList :: [CommandProblem] -> ShowS # | |
| Eq CommandProblem Source # | |
Defined in Configuration.Cfv.Shell Methods (==) :: CommandProblem -> CommandProblem -> Bool # (/=) :: CommandProblem -> CommandProblem -> Bool # | |
data ShellConfig Source #
Shell configuration.
Constructors
| ShellConfig | |
Fields
| |
Instances
| Show ShellConfig Source # | |
Defined in Configuration.Cfv.Shell Methods showsPrec :: Int -> ShellConfig -> ShowS # show :: ShellConfig -> String # showList :: [ShellConfig] -> ShowS # | |
| Eq ShellConfig Source # | |
Defined in Configuration.Cfv.Shell | |
Arguments
| :: ShellConfig | Shell configuration |
| -> Text | Command to execute |
| -> IO (Either CommandError [Char]) |
Evaluate a shell command reading in its System.IO.stdout.
defaultShellConfig :: ShellConfig Source #
Use $SHELL as a login shell: $SHELL -l -c cmd. A login shell picks up
the user's profile (PATH additions and so on). Add "-i" to the flags if
you also need what the shell's interactive rc file sets up (aliases,
functions).
describeProblem :: CommandProblem -> Text Source #
Converts a command problem into a Text.