Shells in OCaml
at main 46 lines 1.3 kB view raw
1open Eio.Std 2(** Shell evaluation. 3 4 This module provides the main evaluator for any shell. It requires users to 5 provide a {! Types.State} module and a {! Types.Exec} module. *) 6 7module Make (S : Types.State) (E : Types.Exec) : sig 8 type ctx 9 (** The context of the evaluation *) 10 11 module J : Types.Job with type process = E.process 12 13 val make_ctx : 14 ?interactive:bool -> 15 ?subshell:bool -> 16 ?local_state:(string * string) list -> 17 ?background_jobs:J.t list -> 18 ?last_background_process:string -> 19 ?functions:(string * Sast.compound_command) list -> 20 ?rdrs:Types.redirect list -> 21 ?exit_handler:(unit -> unit) -> 22 ?options:Built_ins.Options.t -> 23 ?hash:Hash.t -> 24 fs:Eio.Fs.dir_ty Eio.Path.t -> 25 stdin:Eio_unix.source_ty r -> 26 stdout:Eio_unix.sink_ty r -> 27 async_switch:Switch.t -> 28 program:string -> 29 argv:string array -> 30 signal_handler:((unit -> unit) -> unit) -> 31 S.t -> 32 E.t -> 33 ctx 34 35 val fs : ctx -> Eio.Fs.dir_ty Eio.Path.t 36 (** The file system capability *) 37 38 val state : ctx -> S.t 39 (** Return the current state of the context. *) 40 41 val sigint_set : ctx -> bool 42 (** Has the signal SIGINT been set via a trap. *) 43 44 val run : ctx Exit.t -> Ast.t -> ctx Exit.t * Ast.t list 45 (** [run ctx ast] evaluates [ast] using the initial [ctx]. *) 46end