How to ignore Stderr in shake >= 0.15?

16 views
Skip to first unread message

Stefan Kersten

unread,
Jun 16, 2015, 6:05:47 AM6/16/15
to shake-bui...@googlegroups.com
Hello,

in shake < 0.15 I've used the following technique for ignoring a command's stderr output:

(Exit _, Stdout state, Stderr _) <- cmd [adb sdk, "-e", "shell", "getprop", "init.svc.bootanim"]

This code now fails to compile, because the stderr string type is ambiguous:

    No instance for (CmdString t0) arising from a use of ‘cmd’

    The type variable ‘t0’ is ambiguous

    Note: there are several potential instances:

      instance CmdString () -- Defined in ‘Development.Shake.Command’

      instance CmdString

                 bytestring-0.10.4.0:Data.ByteString.Lazy.Internal.ByteString

        -- Defined in ‘Development.Shake.Command’

      instance CmdString

                 bytestring-0.10.4.0:Data.ByteString.Internal.ByteString

        -- Defined in ‘Development.Shake.Command’

      ...plus one other

    In a stmt of a 'do' block:

      (Exit _, Stdout state, Stderr _) <- cmd

                                            [adb sdk, "-e", "shell", "getprop", ....]


Any hints how Stderr can be ignored now, preferably without ScopedTypeVariables?


Thanks and best,

Stefan


Neil Mitchell

unread,
Jun 16, 2015, 6:13:25 AM6/16/15
to Stefan Kersten, shake-bui...@googlegroups.com
Hi Stefan,

Two ways:

(Exit _, Stdout state, Stderr ()) <- cmd [adb sdk, "-e", "shell",
"getprop", "init.svc.bootanim"]

Or:

(Exit _, Stdout state) <- cmd [adb sdk, "-e", "shell", "getprop",
"init.svc.bootanim", WithStderr False, EchoStderr False]

I think both boil down to the same thing. In the first you capture the
Stderr to a value of type (), which is effecitvely discarding the
stderr. In the second you are explicitly declaring that you don't want
the stderr in the error, or to be echo'd.

Note that both of them are significantly more efficient than previous
versions of Shake, which would have captured Stderr
character-by-character only to throw it away at the end.

Thanks, Neil

Stefan Kersten

unread,
Jun 16, 2015, 6:29:24 AM6/16/15
to Neil Mitchell, Stefan Kersten, shake-bui...@googlegroups.com
hi neil,

On 16/06/15 12:13, Neil Mitchell wrote:
> (Exit _, Stdout state, Stderr ()) <- cmd [adb sdk, "-e", "shell",
> "getprop", "init.svc.bootanim"]
>
> Or:
>
> (Exit _, Stdout state) <- cmd [adb sdk, "-e", "shell", "getprop",
> "init.svc.bootanim", WithStderr False, EchoStderr False]

thanks!

> Note that both of them are significantly more efficient than previous
> versions of Shake, which would have captured Stderr
> character-by-character only to throw it away at the end.

great, that's reassuring :)

bst,
stefan
Reply all
Reply to author
Forward
0 new messages