Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	tools/orphan_images/orphimg.kt
  • Loading branch information
holgerbrandl committed Apr 22, 2021
2 parents acb296d + f0cbf36 commit bb71d14
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 83 deletions.
15 changes: 8 additions & 7 deletions src/main/kotlin/de/mpicbg/scicomp/kutils/Bash.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,23 @@ data class BashResult(val exitCode: Int, val stdout: Iterable<String>, val stder
}


fun evalBash(cmd: String, showOutput: Boolean = false,
redirectStdout: File? = null, redirectStderr: File? = null, wd: File? = null): BashResult {
fun evalBash(cmd: String, showOutput: Boolean = false, wd: File? = null): BashResult {

try {

// optionally prefix script with working directory change
val cmd = (if (wd != null) "cd '${wd.absolutePath}'\n" else "") + cmd


var pb = ProcessBuilder("/bin/bash", "-c", cmd) //.inheritIO();
var pb = ProcessBuilder("/bin/bash", "-c", cmd)
if (showOutput) {
pb.inheritIO()
}
pb.directory(File("."));
var p = pb.start();

val outputGobbler = StreamGobbler(p.getInputStream(), if (showOutput) System.out else null)
val errorGobbler = StreamGobbler(p.getErrorStream(), if (showOutput) System.err else null)
val outputGobbler = StreamGobbler(p.getInputStream())
val errorGobbler = StreamGobbler(p.getErrorStream())

// kick them off
errorGobbler.start()
Expand All @@ -40,7 +42,7 @@ fun evalBash(cmd: String, showOutput: Boolean = false,
}


internal class StreamGobbler(var inStream: InputStream, val printStream: PrintStream?) : Thread() {
internal class StreamGobbler(var inStream: InputStream) : Thread() {
var sb = StringBuilder()

override fun run() {
Expand All @@ -49,7 +51,6 @@ internal class StreamGobbler(var inStream: InputStream, val printStream: PrintSt
val br = BufferedReader(isr)
for (line in br.linesJ7()) {
sb.append(line!! + "\n")
printStream?.println(line)
}
} catch (ioe: IOException) {
ioe.printStackTrace()
Expand Down
21 changes: 0 additions & 21 deletions tools/orphan_images/README.md

This file was deleted.

55 changes: 0 additions & 55 deletions tools/orphan_images/orphimg.kt

This file was deleted.

0 comments on commit bb71d14

Please sign in to comment.