echo: "\n" option implemented.

This commit is contained in:
jienfak 2020-01-07 06:22:16 +05:00
parent 1aa0c5d75a
commit 378ca66cd0

View file

@ -7,15 +7,18 @@ import (
)
func Run(args []string) int {
var nflag bool
flagSet := flag.NewFlagSet(args[0], flag.ExitOnError)
flagSet.BoolVar(&nflag, "n", false, "Do not print new line character.")
flagSet.Parse(args[1:])
args = args[1:]
status := 0
args = flagSet.Args()
l := len(args) - 1
for i, s := range args {
fmt.Print(s)
if i!=l { fmt.Print(" ") }
}
if !nflag {
fmt.Print("\n")
return status
}
return 0
}