Skip to content

Commit

Permalink
Add CHANGES and simplify some code
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <[email protected]>
  • Loading branch information
rgrinberg committed Aug 6, 2020
1 parent 27e45aa commit 05fdc42
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ next
- Add `"odoc" {with-doc}` to the dependencies in the generated `.opam` files.
(#3667, @kit-ty-kate)

- Do not allow user actions to capture dune's stdin (#3677, fixes #3672,
@rgrinberg)

2.6.1 (02/07/2020)
------------------

Expand Down
38 changes: 22 additions & 16 deletions src/dune/process.ml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ type purpose =
| Internal_job
| Build_job of Path.Build.Set.t

let io_to_redirection_path (kind : Io.kind) =
match kind with
| Terminal -> None
| Null -> Some (Lazy.force Io.null_path)
| File fn -> Some (Path.to_string fn)

let command_line_enclosers ~dir ~(stdout_to : Io.output Io.t)
~(stderr_to : Io.output Io.t) ~(stdin_from : Io.input Io.t) =
let quote fn = String.quote_for_shell (Path.to_string fn) in
Expand All @@ -156,26 +162,26 @@ let command_line_enclosers ~dir ~(stdout_to : Io.output Io.t)
in
let suffix =
match stdin_from.kind with
| Null -> suffix
| Terminal -> suffix
| Null
| Terminal ->
suffix
| File fn -> suffix ^ " < " ^ quote fn
in
let suffix =
match (stdout_to.kind, stderr_to.kind) with
| File fn1, File fn2 when Path.equal fn1 fn2 -> " &> " ^ quote fn1
| _ -> (
let suffix =
match stdout_to.kind with
| Terminal -> suffix
| Null ->
suffix ^ " > " ^ String.quote_for_shell (Lazy.force Io.null_path)
| File fn -> suffix ^ " > " ^ quote fn
match
( io_to_redirection_path stdout_to.kind
, io_to_redirection_path stderr_to.kind )
with
| Some fn1, Some fn2 when String.equal fn1 fn2 ->
" &> " ^ String.quote_for_shell fn1
| path_out, path_err ->
let add_to_suffix suffix path redirect =
match path with
| None -> suffix
| Some path -> suffix ^ redirect ^ String.quote_for_shell path
in
match stderr_to.kind with
| Terminal -> suffix
| Null ->
suffix ^ " 2> " ^ String.quote_for_shell (Lazy.force Io.null_path)
| File fn -> suffix ^ " 2> " ^ quote fn )
let suffix = add_to_suffix suffix path_out " > " in
add_to_suffix suffix path_err " 2> "
in
(prefix, suffix)

Expand Down

0 comments on commit 05fdc42

Please sign in to comment.