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,) +}