diff --git a/echo/echo.go b/echo/echo.go index 9ee0c81..d9e2229 100644 --- a/echo/echo.go +++ b/echo/echo.go @@ -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(" ") } } - fmt.Print("\n") - return status + if !nflag { + fmt.Print("\n") + } + return 0 }