You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trim trailing newlines in ExitCodeExceptionShow instance
Needs fpco#88.
Previously, output was assumed to end with a newline, leading to poor
`ExitCodeException` rendering (see the "Standard error" header below):
ghci> readProcess_ $ proc "sh" ["-c", "nix path-info --json nixpkgs#agda && false"]
*** Exception: Received ExitFailure 1 when running
Raw command: sh -c "nix path-info --json nixpkgs#agda && false"
Standard output:
[{"path":"/nix/store/sj2z0h5ywlflqv50dfphwia6p0ij0mlj-agdaWithPackages-2.6.4.3","valid":false}]Standard error:
these 5 paths will be fetched (18.30 MiB download, 133.19 MiB unpacked):
/nix/store/5q0kb0nqnqcfs7a0ncsjq4fdppwirpxa-Agda-2.6.4.3-bin
/nix/store/xmximjjnkn0hm4gw7akc9f20ydz6msmk-Agda-2.6.4.3-data
/nix/store/sj2z0h5ywlflqv50dfphwia6p0ij0mlj-agdaWithPackages-2.6.4.3
/nix/store/b49sa2q0yb3fd14ppzh6j6rm8vvgr9n6-ghc-9.6.6-with-packages
/nix/store/vharimf7f2glj4fyhiglzws0qyv4xrry-libraries
Now, trailing newlines are removed and the correct number of newlines
are inserted in order to make the `Show` instance display legibly:
ghci> readProcess_ $ proc "sh" ["-c", "nix path-info --json nixpkgs#agda && false"]
*** Exception: Received ExitFailure 1 when running
Raw command: sh -c "nix path-info --json nixpkgs#agda && false"
Standard output:
[{"path":"/nix/store/sj2z0h5ywlflqv50dfphwia6p0ij0mlj-agdaWithPackages-2.6.4.3","valid":false}]
Standard error:
these 5 paths will be fetched (18.30 MiB download, 133.19 MiB unpacked):
/nix/store/5q0kb0nqnqcfs7a0ncsjq4fdppwirpxa-Agda-2.6.4.3-bin
/nix/store/xmximjjnkn0hm4gw7akc9f20ydz6msmk-Agda-2.6.4.3-data
/nix/store/sj2z0h5ywlflqv50dfphwia6p0ij0mlj-agdaWithPackages-2.6.4.3
/nix/store/b49sa2q0yb3fd14ppzh6j6rm8vvgr9n6-ghc-9.6.6-with-packages
/nix/store/vharimf7f2glj4fyhiglzws0qyv4xrry-libraries
Also, derived `Show` instances will behave correctly now. Previously,
the `Show` instance would often end with a newline, leading to clumsy
output:
ghci> e stdout stderr = ExitCodeException { ... }
ghci> data Foo = Foo { a :: Int, b :: ExitCodeException, c :: String } deriving Show
ghci> Foo 1 (e "<STDOUT>\n" "") "hello"
Foo {a = 1, b = Received ExitFailure 1 when running
Raw command: echo
Standard output:
<STDOUT>
, c = "hello"}
Now:
ghci> Foo 1 (e "<STDOUT>\n" "") "hello"
Foo {a = 1, b = Received ExitFailure 1 when running
Raw command: echo
Standard output:
<STDOUT>, c = "hello"}
0 commit comments