cfv
Copyright(c) Harley Eades 2026
Maintainerharley.eades@gmail.com
Safe HaskellSafe-Inferred
LanguageHaskell2010

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

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).

Instances

Instances details
Show CommandError Source # 
Instance details

Defined in Configuration.Cfv.Shell

Eq CommandError Source # 
Instance details

Defined in Configuration.Cfv.Shell

data CommandProblem Source #

Errors produced by running a command on the shell.

Constructors

NoShell

No shell configured and SHELL is unset or empty.

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 Nothing for a '@Configuration.Cfv.AST.Secret' variable.

OutputNotUtf8 UnicodeException

The command's standard output is not valid UTF-8. The exception names the offending byte, so it is Nothing for a '@Configuration.Cfv.AST.Secret' variable.

data ShellConfig Source #

Shell configuration.

Constructors

ShellConfig 

Fields

Instances

Instances details
Show ShellConfig Source # 
Instance details

Defined in Configuration.Cfv.Shell

Eq ShellConfig Source # 
Instance details

Defined in Configuration.Cfv.Shell

evalValue Source #

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.