package main import ( "fmt" "os" ) // 显示内容并换行 func cmd_echo(fields []string, stdin *os.File, stdout *os.File, stderr *os.File) { for i, str := range fields[1:] { // 遍历参数 if i > 0 { fmt.Fprint(stdout, " ") } fmt.Fprint(stdout, os.ExpandEnv(str)) // 替换环境变量后输出 } fmt.Fprintln(stdout) }