Ammonite icon indicating copy to clipboard operation
Ammonite copied to clipboard

IllegalArgumentException: Unknown ansi-escape [0;93m at index 19 inside string cannot be parsed into an fansi.Str

Open jk-1 opened this issue 1 year ago • 1 comments

I'm trying to run simple ssh-ping command using ammonite but it fails.

ssh-ping is part of small optional Ubuntu package ssh-tools.

On Mate terminal command output when pinging non-existing host is this:

ssh-ping -q -W 2 -c 1 -p 22 myhost
SSHPING myhost

--- myhost ping statistics ---
1 requests transmitted, 0 requests received, 100% request loss

Output is very colored and there is no option in ssh-ping to turn off colors.

Running this with standard Scala REPL works fine:

scala
Welcome to Scala 2.12.8 (OpenJDK 64-Bit Server VM, Java 11.0.18).
Type in expressions for evaluation. Or try :help.

scala> import scala.sys.process._
import scala.sys.process._

scala>  val res = "ssh-ping -q -W 2 -c 1 -p 22 myhost".!!
res: String =
"SSHPING myhost

--- myhost ping statistics ---
1 requests transmitted, 0 requests received, 100% request loss
"

scala> 

But when trying to run the same with Ammonite, I get repeatedly this exception:

amm
Loading...
Welcome to the Ammonite Repl 2.4.0 (Scala 2.12.13 Java 11.0.18)
jk-kptmp@ import scala.sys.process._  
import scala.sys.process._ 

jk-kptmp@ val res = "ssh-ping -q -W 2 -c 1 -p 22 myhost".!! 
java.lang.IllegalArgumentException: Unknown ansi-escape [0;93m at index 19 inside string cannot be parsed into an fansi.Str
  fansi.ErrorMode$Throw$.handle(Fansi.scala:419)
  fansi.ErrorMode$Throw$.handle(Fansi.scala:407)
  fansi.Str$.apply(Fansi.scala:272)
  fansi.Str$.implicitApply(Fansi.scala:227)
  pprint.Renderer.$anonfun$rec$33(Renderer.scala:149)
  pprint.Result$.fromString(Result.scala:53)
  pprint.Renderer.rec(Renderer.scala:149)
  pprint.PPrinter.tokenize(PPrinter.scala:104)
  ammonite.repl.FullReplAPI$Internal.print(FullReplAPI.scala:106)
  ammonite.repl.FullReplAPI$Internal.print$(FullReplAPI.scala:61)
  ammonite.repl.FullReplAPI$$anon$1.print(FullReplAPI.scala:34)

It also fails with Ammonite and os.lib's os.proc(...).call(...) -function.

Versions: Ubuntu 20.04, Ammonite Repl 2.4.0 (Scala 2.12.13 Java 11.0.18)

I opened this issue here because don't know whether this is fansi issue, ammonite issue or common for both packages.

jk-1 avatar Mar 06 '23 10:03 jk-1