Created
January 26, 2015 14:17
-
-
Save twillouer/47d461a35445afe82e27 to your computer and use it in GitHub Desktop.
Process
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> val log = new ProcessLogger { | |
| val sb = new StringBuilder | |
| override def buffer[T](f: => T): T = f | |
| override def out(s: => String): Unit = sb.append(s) | |
| override def err(s: => String): Unit = sb.append(s) | |
| } | |
log: scala.sys.process.ProcessLogger{val sb: StringBuilder} = $anon$1@41385767 | |
scala> ("yes -y 100" #| "head -c 1").!(log) | |
res3: Int = 0 | |
scala> log.sb.toString(); | |
warning: there were 1 feature warning(s); re-run with -feature for details | |
res4: String = yes : option invalide -- 'y'Saisissez « yes --help » pour plus d'informations. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ah oui, mais non. C'est un mauvais exemple de ma part. Le
yes -y
existe sur mac mais pas sur Linux. Du coup, l'erreur est pas la bonne. Dans ce cas, c'est un option invalide et donc le premier process qui close le pipe. Dans mon cas, c'est le head qui clot le pipe et le signale au premier processus. Et c'est dans ce deuxième cas que j'ai une erreur incatchable...