echo: "\n" option implemented.
This commit is contained in:
parent
1aa0c5d75a
commit
378ca66cd0
1 changed files with 7 additions and 4 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue