Commit 61b8b55
committed
Trim trailing newlines in
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"}ExitCodeException Show instance1 parent 685a67a commit 61b8b55
File tree
2 files changed
+67
-19
lines changed- src/System/Process/Typed
- test/System/Process
2 files changed
+67
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
616 | 617 | | |
617 | 618 | | |
618 | 619 | | |
619 | | - | |
620 | | - | |
621 | | - | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
622 | 631 | | |
623 | 632 | | |
624 | 633 | | |
625 | 634 | | |
626 | | - | |
| 635 | + | |
627 | 636 | | |
628 | | - | |
| 637 | + | |
629 | 638 | | |
630 | 639 | | |
631 | 640 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | 237 | | |
241 | 238 | | |
242 | 239 | | |
| |||
252 | 249 | | |
253 | 250 | | |
254 | 251 | | |
255 | | - | |
| 252 | + | |
256 | 253 | | |
257 | 254 | | |
258 | 255 | | |
| |||
268 | 265 | | |
269 | 266 | | |
270 | 267 | | |
271 | | - | |
| 268 | + | |
272 | 269 | | |
273 | 270 | | |
274 | 271 | | |
| |||
282 | 279 | | |
283 | 280 | | |
284 | 281 | | |
| 282 | + | |
285 | 283 | | |
286 | | - | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
287 | 329 | | |
288 | | - | |
289 | | - | |
290 | | - | |
| 330 | + | |
291 | 331 | | |
292 | 332 | | |
293 | 333 | | |
| |||
300 | 340 | | |
301 | 341 | | |
302 | 342 | | |
303 | | - | |
304 | | - | |
| 343 | + | |
| 344 | + | |
305 | 345 | | |
306 | | - | |
| 346 | + | |
307 | 347 | | |
308 | 348 | | |
309 | 349 | | |
| |||
324 | 364 | | |
325 | 365 | | |
326 | 366 | | |
327 | | - | |
328 | | - | |
329 | 367 | | |
330 | 368 | | |
331 | 369 | | |
| |||
339 | 377 | | |
340 | 378 | | |
341 | 379 | | |
| 380 | + | |
342 | 381 | | |
343 | 382 | | |
0 commit comments