2019-09-24 20:19:01 +03:00
|
|
|
/* Simple 'echo' implementation. */
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-09-26 03:25:23 +03:00
|
|
|
"flag"
|
2019-09-24 20:19:01 +03:00
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2019-09-26 03:25:23 +03:00
|
|
|
newLineFlagPtr := flag.Bool("n", false,
|
|
|
|
"Don't add new line character('-N' is lower priority).")
|
|
|
|
newLineStrPtr := flag.String("N", "\n", "Use this instead new line character.")
|
|
|
|
joinStrsFlagPtr := flag.Bool("j", false, "Join strings('-J' is lower priority).")
|
|
|
|
joinStrPtr := flag.String("J", " ", "Use instead of space as separator.")
|
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
if *newLineFlagPtr {
|
|
|
|
*newLineStrPtr = ""
|
|
|
|
}
|
|
|
|
if *joinStrsFlagPtr {
|
|
|
|
*joinStrPtr = ""
|
2019-09-24 20:19:01 +03:00
|
|
|
}
|
2019-09-26 03:25:23 +03:00
|
|
|
|
2019-09-24 20:19:01 +03:00
|
|
|
fmt.Printf("%s%s",
|
2019-09-26 03:25:23 +03:00
|
|
|
strings.Join(flag.Args(), *joinStrPtr),
|
|
|
|
*newLineStrPtr,)
|
2019-09-24 20:19:01 +03:00
|
|
|
}
|