diff --git a/src/lib/eval.ml b/src/lib/eval.ml index ee7f53e..fae5ce8 100644 --- a/src/lib/eval.ml +++ b/src/lib/eval.ml @@ -364,7 +364,7 @@ module Make (S : Types.State) (E : Types.Exec) = struct match executable with | "export" -> let updated = - handle_export_or_readonly `Export ctx args + handle_assignments `Export ctx args in let job = handle_job job @@ -374,7 +374,17 @@ module Make (S : Types.State) (E : Types.Exec) = struct rest | "readonly" -> let updated = - handle_export_or_readonly `Readonly ctx args + handle_assignments `Readonly ctx args + in + let job = + handle_job job + (`Built_in (updated >|= fun _ -> ())) + in + loop (Exit.value updated) job stdout_of_previous + rest + | "local" -> + let updated = + handle_assignments `Local ctx args in let job = handle_job job @@ -835,7 +845,7 @@ module Make (S : Types.State) (E : Types.Exec) = struct in (Exit.zero ctx, List.concat cst) - and handle_export_or_readonly kind ctx (assignments : string list) = + and handle_assignments kind ctx (assignments : string list) = let flags, assignments = List.fold_left (fun (fs, args) v -> @@ -848,6 +858,9 @@ module Make (S : Types.State) (E : Types.Exec) = struct match kind with | `Export -> update ~export:true ~readonly:false | `Readonly -> update ~export:false ~readonly:true + | `Local -> + fun ctx ~param v -> + Exit.zero { ctx with local_state = (param, v) :: ctx.local_state } in let read_arg acc_ctx param = (* TODO: quoting? *) @@ -869,6 +882,7 @@ module Make (S : Types.State) (E : Types.Exec) = struct match kind with | `Readonly -> S.pp_readonly Fmt.stdout ctx.state | `Export -> S.pp_export Fmt.stdout ctx.state + | `Local -> () end; Exit.zero ctx diff --git a/src/lib/types.ml b/src/lib/types.ml index 36355d6..15700a8 100644 --- a/src/lib/types.ml +++ b/src/lib/types.ml @@ -31,7 +31,8 @@ module type State = sig string -> (t, string) result (** Update the state with a new parameter mapping and whether or not it should - exported to the environment (default false). *) + exported to the environment (default false), if it is readonly (default + false). *) val remove : param:string -> t -> bool * t (** [remove ~param t] removes [param] from [t] if it exists. [bool] is [true]