fb-adb - 改良版adb shell

Facebookが adb shell の改良版を開発しているみたい。

https://github.com/facebook/fb-adb

"adb"とつけてはいるけど、実際には"adb shell" と "adb rcmd" だけを処理して他のサブコマンドはadbにフォワードしているだけ。

改良したところはREADMEによれば以下の点だ。

  • Binary clean (no LF -> CRLF mangling)
  • transmits and updates window size
  • distinguishes standard output and standard error
  • properly muxes streams with independent flow control
  • allows for ssh-like pty allocation control
  • propagates program exit status instead of always exiting with status 0
  • properly escapes program arguments
  • kills remote program
  • provides a generic facility to elevate to root without re-escaping

ざっくり言うと、いろいろまともにしたってことだけど、特に「adb shell $command」のstatus codeを返すようにした」とか「adb shellのstderrをちゃんとstderrとして出すようにした」あたりはかなりうれしくて、adbをwrapするツールを作りやすくなったと思われる。

例:

# exit status
$ adb shell false
$ echo $?
0

$ fb-adb shell false
$ echo $?
1

# stderr
$  adb shell 'echo foo >&2' >/dev/null # 何も表示されない
$  fb-adb shell 'echo foo >&2' >/dev/null
foo


当初GenyMotionで動かない という問題がありましたが、現在は解消されています。