mirror of https://github.com/sbt/sbt.git
Allow trailing semicolon in multi commands
It was a mistake to disallow trailing semicolons for multi commands. Firstly this was a mistake because previous versions of sbt supported a trailing semi colon. It was also inconsistent with how commands work in a regular shell (e.g. bash or zsh).
This commit is contained in:
parent
1e7564c408
commit
9634a872cd
|
|
@ -163,7 +163,7 @@ object BasicCommands {
|
|||
)
|
||||
def commandParser = state.map(s => (s.combinedParser & cmdPart) | cmdPart).getOrElse(cmdPart)
|
||||
val part = semi.flatMap(_ => matched(commandParser) <~ token(OptSpace)).map(_.trim)
|
||||
(cmdPart.? ~ part.+).map {
|
||||
(cmdPart.? ~ part.+ <~ semi.?).map {
|
||||
case (Some(h), t) => h.mkString.trim +: t.toList
|
||||
case (_, t) => t.toList
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,5 +61,10 @@ class MultiParserSpec extends FlatSpec with Matchers {
|
|||
"foo bar baz".parseEither shouldBe Left("Expected ';'\nfoo bar baz\n ^")
|
||||
"foo bar baz;".parseEither shouldBe
|
||||
Left("Expected not ';'\nExpected '\"'\nfoo bar baz;\n ^")
|
||||
"foo;".parseEither shouldBe Left("Expected not ';'\nExpected '\"'\nfoo;\n ^")
|
||||
}
|
||||
it should "parse commands with trailing semi-colon" in {
|
||||
"foo;bar;".parse shouldBe Seq("foo", "bar")
|
||||
"foo; bar ;".parse shouldBe Seq("foo", "bar")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,5 +17,5 @@
|
|||
|
||||
# All of the other tests have involved input tasks, so include commands with regular tasks as well.
|
||||
> ~; compile; setStringValue baz; checkStringValue baz
|
||||
# No trailing semicolons are allowed
|
||||
-> ~; compile; setStringValue baz; checkStringValue baz;
|
||||
# Ensure that trailing semi colons work
|
||||
> ~ compile; setStringValue baz; checkStringValue baz;
|
||||
|
|
|
|||
Loading…
Reference in New Issue