Skip to content

Commit

Permalink
Lua関数 nyagos.echo がエスケープシーケンスに対応していなかった
Browse files Browse the repository at this point in the history
  • Loading branch information
hymkor committed Oct 1, 2014
1 parent 9cb52aa commit 19ed105
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lua.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import "./dos"
import "./interpreter"
import "./mbcs"

import "github.com/shiena/ansicolor"

const nyagos_exec_cmd = "nyagos.exec.cmd"

type LuaFunction struct {
Expand Down Expand Up @@ -150,19 +152,15 @@ func cmdEval(L *Lua) int {
}

func cmdEcho(L *Lua) int {
var out io.Writer
var out io.Writer = os.Stdout
L.GetField(Registory, nyagos_exec_cmd)
if L.GetType(-1) == TLIGHTUSERDATA {
cmd := (*exec.Cmd)(L.ToUserData(-1))
if cmd != nil {
if cmd := (*exec.Cmd)(L.ToUserData(-1)); cmd != nil {
out = cmd.Stdout
} else {
out = os.Stdout
}
} else {
out = os.Stdout
}
L.Pop(1)
out = ansicolor.NewAnsiColorWriter(out)

n := L.GetTop()
for i := 1; i <= n; i++ {
Expand Down

0 comments on commit 19ed105

Please sign in to comment.