I've tried the following so far:
me@pc:~/code$ ghc file.hs -Wall | tee warnings.log
me@pc:~/code$ ghc file.hs -Wall > warnings.log
But ghc
just prints the warnings like normal and only passes on the non-warning steps.
Is there a way to do this?
The reason why it still shows these warnings is because warnings and errors are printed on the standard error channel (stderr).
You can thus redirect the errors to a file by redirecting the stderr, with:
ghc file.hs -Wall warnings.log
Notice the 2
in >
. > 。 As said before, both the warnings and the exceptions are printed to this channel.
We can redirect the error stream to tee
in bash
with:
ghc -Wall file.hs
this features works for bash
, but as far as I know, this is not defined in the POSIX standard. For bash
this works, but for sh
, this seems to fail.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.