Skip to content

Commit

Permalink
Merge pull request #666 from talex5/quote-args
Browse files Browse the repository at this point in the history
Fix quoting of quotes in process error messages
  • Loading branch information
talex5 authored Jan 8, 2024
2 parents 4856fc4 + 81bce87 commit cfafb22
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib_eio/process.ml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ let bad_char = function
c <= 32 || c >= 127

let pp_arg f x =
if x = "" || String.exists bad_char x then Fmt.(quote string) f x
if x = "" || String.exists bad_char x then Fmt.pf f "%S" x
else Fmt.string f x

let pp_args = Fmt.hbox (Fmt.list ~sep:Fmt.sp pp_arg)
Expand Down
4 changes: 2 additions & 2 deletions tests/process.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ If a command fails, we get shown the arguments (quoted if necessary):

```ocaml
# run @@ fun mgr env ->
Process.run mgr ["bash"; "-c"; "exit 3"; ""; "foo"];;
Process.run mgr ["bash"; "-c"; "exit 3"; ""; "foo"; "\"bar\""];;
Exception:
Eio.Io Process Child_error Exited (code 3),
running command: bash -c "exit 3" "" foo
running command: bash -c "exit 3" "" foo "\"bar\""
```

Exit code success can be determined by is_success (Process.run):
Expand Down

0 comments on commit cfafb22

Please sign in to comment.