From 277a9971131b3806fac9138bd4e5305b9c22d9eb Mon Sep 17 00:00:00 2001 From: jienfak Date: Tue, 24 Sep 2019 22:19:01 +0500 Subject: [PATCH] Init commit. +The simplest 'echo' realisation added. --- newnix/README.txt | 5 +++++ newnix/echo/main.go | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 newnix/README.txt create mode 100644 newnix/echo/main.go diff --git a/newnix/README.txt b/newnix/README.txt new file mode 100644 index 0000000..86a7c2d --- /dev/null +++ b/newnix/README.txt @@ -0,0 +1,5 @@ +New implementations with no dependence +on POSIX and other old shit. +There are too many stupid things +on options to put all of this in +one implementation only. diff --git a/newnix/echo/main.go b/newnix/echo/main.go new file mode 100644 index 0000000..ae8bac0 --- /dev/null +++ b/newnix/echo/main.go @@ -0,0 +1,22 @@ +/* Simple 'echo' implementation. */ +package main + +import ( + "fmt" + "strings" + "os" +) + +func main() { + strsId := 1 + firstOpt := os.Args[strsId] + nextLineStr := "\n" + joinStr := " " + if firstOpt == "-n" { + nextLineStr = "" + strsId += 1 + } + fmt.Printf("%s%s", + strings.Join(os.Args[strsId:], joinStr), + nextLineStr,) +}