correct echo utility etc.
This commit is contained in:
parent
2f6f90dce4
commit
5de50196ea
7 changed files with 19 additions and 10 deletions
4
echo.nim
4
echo.nim
|
|
@ -2,8 +2,8 @@ import cligen, sequtils
|
|||
import common
|
||||
|
||||
proc main(strings:seq[string], newline=true) =
|
||||
if newline: writeLine(stdout, strings.foldl(a & b))
|
||||
else: write(stdout, strings.foldl(a & b))
|
||||
if newline: writeLine(stdout, strings.foldl(a & " " & b))
|
||||
else: write(stdout, strings.foldl(a & " " & b))
|
||||
flushFile(stdout)
|
||||
|
||||
dispatch(main, version=("version", nimbaseVersion))
|
||||
|
|
|
|||
11
head.nim
11
head.nim
|
|
@ -5,16 +5,17 @@ proc main(files:seq[string], lines=10, bytes=0) =
|
|||
# if files.len == 0:
|
||||
# files.add "-"
|
||||
for file in files:
|
||||
var s = newFileStream(file, fmRead)
|
||||
var f = if file == "-": stdin
|
||||
else: open(file, fmRead)
|
||||
if bytes > 0:
|
||||
var currentByte = 0
|
||||
while not s.atEnd and currentByte < bytes:
|
||||
write(stdout, s.readChar)
|
||||
while not f.endOfFile and currentByte < bytes:
|
||||
write(stdout, f.readChar)
|
||||
inc currentByte
|
||||
elif lines > 0:
|
||||
var currentLine = 0
|
||||
while not s.atEnd and currentLine < lines:
|
||||
echo s.readLine
|
||||
while not f.endOfFile and currentLine < lines:
|
||||
writeLine(stdout, f.readLine)
|
||||
inc currentLine
|
||||
|
||||
dispatch(main, version=("version", nimbaseVersion))
|
||||
|
|
|
|||
|
|
@ -8,6 +8,6 @@ requires "nim >= 0.19.0"
|
|||
requires "cligen >= 0.9.19"
|
||||
requires "stint >= 0.0.1"
|
||||
|
||||
bin = @["add", "cat", "cp", "div", "echo", "factor", "false", "head", "mkdir", "mul", "pwd", "rm", "seq", "sleep", "sub", "tee", "touch", "true", "yes"]
|
||||
bin = @["add", "cat", "cp", "div", "echo", "factor", "false", "head", "mkdir", "mul", "pwd", "rm", "seq", "shuf", "sleep", "sub", "tee", "touch", "true", "yes"]
|
||||
|
||||
binDir = "bin"
|
||||
|
|
|
|||
0
rev.nim
Normal file
0
rev.nim
Normal file
4
rm.nim
4
rm.nim
|
|
@ -12,10 +12,10 @@ proc main(files:seq[string], force=false, recursive=false) =
|
|||
if recursive:
|
||||
removeDir(file)
|
||||
else:
|
||||
echo errorMsg & file & "': Is a directory"
|
||||
err errorMsg & file & "': Is a directory"
|
||||
programResult = 1
|
||||
else:
|
||||
echo errorMsg & file & "': No such file or directory"
|
||||
err errorMsg & file & "': No such file or directory"
|
||||
programResult = 1
|
||||
|
||||
dispatch(main, version=("version", nimbaseVersion))
|
||||
|
|
|
|||
8
shuf.nim
Normal file
8
shuf.nim
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import cligen
|
||||
import common
|
||||
|
||||
proc main(files:seq[string]) =
|
||||
for file in files:
|
||||
echo ""
|
||||
|
||||
dispatch(main, version=("version", nimbaseVersion))
|
||||
0
tac.nim
Normal file
0
tac.nim
Normal file
Loading…
Add table
Add a link
Reference in a new issue