Shells in OCaml
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

Non-posix local

A really poor approximation for `local` variables. This is not POSIX.

+19 -4
+17 -3
src/lib/eval.ml
··· 364 364 match executable with 365 365 | "export" -> 366 366 let updated = 367 - handle_export_or_readonly `Export ctx args 367 + handle_assignments `Export ctx args 368 368 in 369 369 let job = 370 370 handle_job job ··· 374 374 rest 375 375 | "readonly" -> 376 376 let updated = 377 - handle_export_or_readonly `Readonly ctx args 377 + handle_assignments `Readonly ctx args 378 + in 379 + let job = 380 + handle_job job 381 + (`Built_in (updated >|= fun _ -> ())) 382 + in 383 + loop (Exit.value updated) job stdout_of_previous 384 + rest 385 + | "local" -> 386 + let updated = 387 + handle_assignments `Local ctx args 378 388 in 379 389 let job = 380 390 handle_job job ··· 835 845 in 836 846 (Exit.zero ctx, List.concat cst) 837 847 838 - and handle_export_or_readonly kind ctx (assignments : string list) = 848 + and handle_assignments kind ctx (assignments : string list) = 839 849 let flags, assignments = 840 850 List.fold_left 841 851 (fun (fs, args) v -> ··· 848 858 match kind with 849 859 | `Export -> update ~export:true ~readonly:false 850 860 | `Readonly -> update ~export:false ~readonly:true 861 + | `Local -> 862 + fun ctx ~param v -> 863 + Exit.zero { ctx with local_state = (param, v) :: ctx.local_state } 851 864 in 852 865 let read_arg acc_ctx param = 853 866 (* TODO: quoting? *) ··· 869 882 match kind with 870 883 | `Readonly -> S.pp_readonly Fmt.stdout ctx.state 871 884 | `Export -> S.pp_export Fmt.stdout ctx.state 885 + | `Local -> () 872 886 end; 873 887 Exit.zero ctx 874 888
+2 -1
src/lib/types.ml
··· 31 31 string -> 32 32 (t, string) result 33 33 (** Update the state with a new parameter mapping and whether or not it should 34 - exported to the environment (default false). *) 34 + exported to the environment (default false), if it is readonly (default 35 + false). *) 35 36 36 37 val remove : param:string -> t -> bool * t 37 38 (** [remove ~param t] removes [param] from [t] if it exists. [bool] is [true]