diff --git a/src/lib/built_ins.ml b/src/lib/built_ins.ml index 5b6251d..42bdc38 100644 --- a/src/lib/built_ins.ml +++ b/src/lib/built_ins.ml @@ -30,6 +30,14 @@ module Options = struct type merry = [ `Async ] type option = [ posix | merry ] + let posix_to_letter = function + | `Noclobber -> "C" + | _ -> "" + + let to_letters t = + let nc = if t.noclobber then posix_to_letter `Noclobber else "" in + nc ^ "" + let update t options = List.fold_left (fun d -> function diff --git a/src/lib/built_ins.mli b/src/lib/built_ins.mli index 641011e..2836b67 100644 --- a/src/lib/built_ins.mli +++ b/src/lib/built_ins.mli @@ -7,6 +7,8 @@ module Options : sig async : bool; } + val to_letters : t -> string + type posix = [ `Noclobber | `Pipefail | `Noglob | `Nounset ] type merry = [ `Async ] type option = [ posix | merry ] diff --git a/src/lib/eunix.ml b/src/lib/eunix.ml index 1d2f09a..30d7345 100644 --- a/src/lib/eunix.ml +++ b/src/lib/eunix.ml @@ -25,11 +25,9 @@ let delegate_control ~pgid fn = let shell_pid = Unix.getpid () in Fun.protect ~finally:(fun () -> - Fmt.pr "Back to the shell\n%!"; let _ : int = tcsetpgrp 0 shell_pid in ()) (fun () -> - Fmt.pr "Delegating...\n%!"; match tcsetpgrp (Obj.magic Unix.stdin : int) pgid with | 0 -> fn () | n -> Fmt.failwith "tcsetpgrp: %i" n) diff --git a/src/lib/eval.ml b/src/lib/eval.ml index 20e5524..0b0cc39 100644 --- a/src/lib/eval.ml +++ b/src/lib/eval.ml @@ -604,6 +604,11 @@ module Make (S : Types.State) (E : Types.Exec) = struct expand ([ Ast.WordName ctx.last_background_process ] :: acc) ctx rest + | Ast.VariableAtom ("-", NoAttribute) -> + let i = if ctx.interactive then "i" else "" in + expand + ([ Ast.WordName (Built_ins.Options.to_letters ctx.options ^ i) ] :: acc) + ctx rest | Ast.VariableAtom (n, NoAttribute) when Option.is_some (int_of_string_opt n) -> ( let n = int_of_string n in