Misc refinements

This commit is contained in:
Mygod
2018-10-03 15:02:07 +08:00
parent c573a68ee1
commit 913e21328e
4 changed files with 33 additions and 34 deletions

View File

@@ -85,11 +85,13 @@ class RootSession : AutoCloseable {
*/
fun submit(command: String) {
val result = execQuiet(command)
if (result.code != 0) Timber.v("$command exited with ${result.code}")
var msg = result.err.joinToString("\n").trim()
if (msg.isNotEmpty()) Timber.v(msg)
msg = result.out.joinToString("\n").trim()
if (msg.isNotEmpty()) Timber.v(msg)
val err = result.err.joinToString("\n") { "E $it" }.trim()
val out = result.out.joinToString("\n").trim()
if (result.code != 0 || err.isNotEmpty() || out.isNotEmpty()) {
Timber.v("$command exited with ${result.code}")
if (err.isNotEmpty()) Timber.v(err)
if (out.isNotEmpty()) Timber.v(out)
}
}
fun execQuiet(command: String, redirect: Boolean = false): Shell.Result {