Skip to content

Commit 094e4fb

Browse files
authored
Repl: emit warning for the :sh command (#22694)
Fixes #21657
2 parents 6feb022 + 9181b55 commit 094e4fb

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

Diff for: compiler/src/dotty/tools/repl/ParseResult.scala

+7
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ object Reset {
100100
val command: String = ":reset"
101101
}
102102

103+
/** `:sh <command line>` run a shell command (result is implicitly => List[String]) */
104+
case class Sh(expr: String) extends Command
105+
object Sh {
106+
val command: String = ":sh"
107+
}
108+
103109
/** Toggle automatic printing of results */
104110
case object Silent extends Command:
105111
val command: String = ":silent"
@@ -150,6 +156,7 @@ object ParseResult {
150156
TypeOf.command -> (arg => TypeOf(arg)),
151157
DocOf.command -> (arg => DocOf(arg)),
152158
Settings.command -> (arg => Settings(arg)),
159+
Sh.command -> (arg => Sh(arg)),
153160
Silent.command -> (_ => Silent),
154161
)
155162

Diff for: compiler/src/dotty/tools/repl/ReplDriver.scala

+4
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,10 @@ class ReplDriver(settings: Array[String],
538538
}
539539
state
540540

541+
case Sh(expr) =>
542+
out.println(s"""The :sh command is deprecated. Use `import scala.sys.process._` and `"command".!` instead.""")
543+
state
544+
541545
case Settings(arg) => arg match
542546
case "" =>
543547
given ctx: Context = state.context

Diff for: compiler/test-resources/repl/i21657

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
scala>:sh
2+
The :sh command is deprecated. Use `import scala.sys.process._` and `"command".!` instead.

Diff for: compiler/test/dotty/tools/repl/TabcompleteTests.scala

+1
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ class TabcompleteTests extends ReplTest {
218218
":quit",
219219
":reset",
220220
":settings",
221+
":sh",
221222
":silent",
222223
":type"
223224
),

0 commit comments

Comments
 (0)