Ugh, sadly, we want it to redirect stdout on the device, so neither case works for userdebug:

    $ adb shell su -c 'echo x > /data/foo'
    su: exec failed for echo x > /data/foo Error:No such file or directory

    $ adb shell su -c echo x > /data/foo
    -bash: /data/local/tmp/foo: No such file or directory

Luckily, the [su.c source](https://github.com/plattypus/Android-4.0.1_r1.0/blob/master/system/extras/su/su.c) says we can do:

    $ adb shell su 0 ls /data/
    app
    ...

    $ adb shell su 0 sh -c 'echo x > /data/foo'

    $ adb shell su 0 cat /data/foo
    x

    $ adb shell su 0 echo x
    su: exec failed for echo Error:No such file or directory

    $ adb shell su 0 sh -c 'echo x'
    x

So, maybe the rule should be:

    if  `adb shell su -c 'echo x'`   returns  'x':
        use 'adb', ['-s', deviceId, 'shell', 'su', '-c', args.join(' ')]
    else:
        use 'adb', ['-s', deviceId, 'shell', 'su', '0', 'sh', '-c', args.join(' ')]