mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-05 03:17:50 +08:00
eval: Add builtin "print"
This commit is contained in:
parent
39abd54013
commit
29061872c7
|
@ -1,5 +1,9 @@
|
|||
package eval
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type ioType byte
|
||||
|
||||
const (
|
||||
|
@ -17,6 +21,7 @@ type builtin struct {
|
|||
|
||||
var builtins = map[string]builtin {
|
||||
"put": builtin{implPut, [3]ioType{unusedIO, chanIO}},
|
||||
"print": builtin{implPrint, [3]ioType{unusedIO}},
|
||||
}
|
||||
|
||||
func implPut(args []string, ios [3]*io) {
|
||||
|
@ -25,3 +30,14 @@ func implPut(args []string, ios [3]*io) {
|
|||
out <- args[i]
|
||||
}
|
||||
}
|
||||
|
||||
func implPrint(args []string, ios [3]*io) {
|
||||
out := ios[1].f
|
||||
|
||||
args = args[1:]
|
||||
args_if := make([]interface{}, len(args))
|
||||
for i, a := range args {
|
||||
args_if[i] = a
|
||||
}
|
||||
fmt.Fprint(out, args_if...)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user