restore missing piece of alias body that prevents looping

This commit is contained in:
Mark Harrah 2011-03-06 08:21:16 -05:00
parent 15e40d4172
commit 3a85bd47d6
2 changed files with 6 additions and 5 deletions

View File

@ -95,7 +95,7 @@ object BuiltinCommands
val name = token(OpOrID.examples( aliasNames(s) : _*) )
val assign = token(Space ~ '=' ~ OptSpace)
val sfree = removeAliases(s)
val to = matched(Command.combine(sfree.processors)(sfree), partial = true) | any.+.string
val to = matched(sfree.combinedParser, partial = true) | any.+.string
val base = (OptSpace ~> (name ~ (assign ~> to.?).?).?)
applyEffect(base)(t => runAlias(s, t) )
}
@ -112,8 +112,7 @@ object BuiltinCommands
def shell = Command.command(Shell, ShellBrief, ShellDetailed) { s =>
val history = (s get historyPath.key) getOrElse Some((s.baseDir / ".history").asFile)
val prompt = (s get shellPrompt.key) match { case Some(pf) => pf(s); case None => "> " }
val parser = Command.combine(s.processors)
val reader = new FullReader(history, parser(s))
val reader = new FullReader(history, s.combinedParser)
val line = reader.readLine(prompt)
line match {
case Some(line) => s.copy(onFailure = Some(Shell), commands = line +: Shell +: s.commands)
@ -430,7 +429,7 @@ object BuiltinCommands
def newAlias(name: String, value: String): Command =
Command.make(name, (name, "'" + value + "'"), "Alias of '" + value + "'")(aliasBody(name, value)).tag(CommandAliasKey, (name, value))
def aliasBody(name: String, value: String)(state: State): Parser[() => State] =
Parser(Command.combine(state.processors)(state))(value)
Parser(Command.combine(removeAlias(state,name).processors)(state))(value)
val CommandAliasKey = AttributeKey[(String,String)]("is-command-alias")
}

View File

@ -14,7 +14,9 @@ final case class State(
commands: Seq[String],
attributes: AttributeMap,
next: Next.Value
) extends Identity
) extends Identity {
lazy val combinedParser = Command.combine(processors)(this)
}
trait Identity {
override final def hashCode = super.hashCode