Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix quoting of quotes in process error messages #666

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading