Skip to content

Add support for the :sh command in the REPL #21657

Closed
@Gedochao

Description

@Gedochao

The :sh command was (and is) supported by the Scala 2 REPL, while it is visibly absent in Scala 3.

scala -S 2.13
Welcome to Scala 2.13.15 (OpenJDK 64-Bit Server VM, Java 17).
Type in expressions for evaluation. Or try :help.
scala> :help
All commands can be abbreviated, e.g., :he instead of :help.
(...)
:sh <command line>       run a shell command (result is implicitly => List[String])
(...)
scala> :sh scala-cli --help
val res9: scala.tools.nsc.interpreter.shell.ProcessResult = `scala-cli --help` (54 lines, exit 0)

scala> res9.lines.mkString(System.lineSeparator)
val res10: String =
Usage: scala-cli <COMMAND>
Scala CLI is a command-line tool to interact with the Scala language. It lets you compile, run and test your Scala code.

Main commands:
  clean                  Clean the workspace.
  compile                Compile Scala code.
  doc                    Generate Scaladoc documentation.
  fmt, format, scalafmt  Formats Scala code.
  repl, console          Fire-up a Scala REPL.
  run                    Compile and run Scala code.
  test                   Compile and test Scala code.

Miscellaneous commands:
  version  Prints the version of the Scala CLI and the default version of Scala.

Other commands:
  config    ...

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions