diff options
Diffstat (limited to 'gils')
| -rw-r--r-- | gils/cat.rv | 2 | ||||
| -rw-r--r-- | gils/cp.rv | 4 | ||||
| -rw-r--r-- | gils/gils.rv | 2 | ||||
| -rw-r--r-- | gils/head.rv | 4 | ||||
| -rw-r--r-- | gils/mkdir.rv | 2 | ||||
| -rw-r--r-- | gils/mv.rv | 4 | ||||
| -rw-r--r-- | gils/rm.rv | 2 | ||||
| -rw-r--r-- | gils/tail.rv | 4 | ||||
| -rw-r--r-- | gils/touch.rv | 4 | ||||
| -rw-r--r-- | gils/tree.rv | 4 | ||||
| -rw-r--r-- | gils/wc.rv | 4 |
11 files changed, 18 insertions, 18 deletions
diff --git a/gils/cat.rv b/gils/cat.rv index 220ce93..0666304 100644 --- a/gils/cat.rv +++ b/gils/cat.rv @@ -2,7 +2,7 @@ const context = env.ctx const parsed = arg_name(context.rest, 0) -if parsed.name:len() == 0 do puts("usage: cat <path>\n") end +if parsed.name:len() == 0 do fail("usage: cat <path>\n") end else do const path = expand_path(parsed.name) if vfs_owns(path) do vfs_cat(path) end @@ -2,12 +2,12 @@ # HAAAAAANNNNKKKK const context = env.ctx -if context.argv:len() < 3 do puts("usage: cp <source> <destination>\n") end +if context.argv:len() < 3 do fail("usage: cp <source> <destination>\n") end else do const source = expand_path(context.argv[1]) const destination = expand_path(context.argv[2]) const size = fs:size(source) - if size < 0 do puts("cp: #{source}: no such file\n") end + if size < 0 do fail("cp: #{source}: no such file\n") end else do const contents = if size > 0 fs:read_bytes(source, 0, size) else "" if fs:store(destination, contents) == 1 do puts("#{source} -> #{destination}\n") end diff --git a/gils/gils.rv b/gils/gils.rv index 08c97cd..a500322 100644 --- a/gils/gils.rv +++ b/gils/gils.rv @@ -39,7 +39,7 @@ fn run_script_path(path, label, ctx) do if size < 0 return :false env.ctx = ctx const error_msg = eval_script(fs:read_bytes(path, 0, size)) - if error_msg != :nil do puts("#{label}: #{error_msg}\n") end + if error_msg != :nil do fail("#{label}: #{error_msg}\n") end return :true end diff --git a/gils/head.rv b/gils/head.rv index addd11a..2c2a82f 100644 --- a/gils/head.rv +++ b/gils/head.rv @@ -13,13 +13,13 @@ fn file_lines(path) do end const context = env.ctx -if context.argv:len() < 2 do puts("usage: head [n] <path>\n") end +if context.argv:len() < 2 do fail("usage: head [n] <path>\n") end else do let limit = 10 let path_arg = context.argv[1] if (context.argv:len() >= 3 and parse_pid(context.argv[1]) >= 0) do limit = parse_pid(context.argv[1]) path_arg = context.argv[2] end const lines = file_lines(expand_path(path_arg)) - if lines == :nil do puts("head: no such file\n") end + if lines == :nil do fail("head: no such file\n") end else do let index = 0 while (index < lines:len() and index < limit) do puts("#{lines[index]}\n") index += 1 end diff --git a/gils/mkdir.rv b/gils/mkdir.rv index 759544e..c7d12f7 100644 --- a/gils/mkdir.rv +++ b/gils/mkdir.rv @@ -1,5 +1,5 @@ # make a directory const context = env.ctx -if context.argv:len() < 2 do puts("usage: mkdir <path>\n") end +if context.argv:len() < 2 do fail("usage: mkdir <path>\n") end else do fs:mkdir(expand_path(context.argv[1])) end @@ -1,12 +1,12 @@ # move or rename a file const context = env.ctx -if context.argv:len() < 3 do puts("usage: mv <source> <destination>\n") end +if context.argv:len() < 3 do fail("usage: mv <source> <destination>\n") end else do const source = expand_path(context.argv[1]) const destination = expand_path(context.argv[2]) const size = fs:size(source) - if size < 0 do puts("mv: #{source}: no such file\n") end + if size < 0 do fail("mv: #{source}: no such file\n") end else do const contents = if size > 0 fs:read_bytes(source, 0, size) else "" if fs:store(destination, contents) == 1 do fs:unlink(source) puts("#{source} -> #{destination}\n") end @@ -2,5 +2,5 @@ const context = env.ctx const parsed = arg_name(context.rest, 0) -if parsed.name:len() == 0 do puts("usage: rm <path>\n") end +if parsed.name:len() == 0 do fail("usage: rm <path>\n") end else do fs:rm(expand_path(parsed.name)) end diff --git a/gils/tail.rv b/gils/tail.rv index 4a661b4..c1ca124 100644 --- a/gils/tail.rv +++ b/gils/tail.rv @@ -14,13 +14,13 @@ fn file_lines(path) do end const context = env.ctx -if context.argv:len() < 2 do puts("usage: tail [n] <path>\n") end +if context.argv:len() < 2 do fail("usage: tail [n] <path>\n") end else do let limit = 10 let path_arg = context.argv[1] if (context.argv:len() >= 3 and parse_pid(context.argv[1]) >= 0) do limit = parse_pid(context.argv[1]) path_arg = context.argv[2] end const lines = file_lines(expand_path(path_arg)) - if lines == :nil do puts("tail: no such file\n") end + if lines == :nil do fail("tail: no such file\n") end else do let start = lines:len() - limit if start < 0 do start = 0 end diff --git a/gils/touch.rv b/gils/touch.rv index 84ecca8..f8e3e18 100644 --- a/gils/touch.rv +++ b/gils/touch.rv @@ -1,9 +1,9 @@ # dont touch my nono square const context = env.ctx -if context.argv:len() < 2 do puts("usage: touch <path>\n") end +if context.argv:len() < 2 do fail("usage: touch <path>\n") end else do const path = expand_path(context.argv[1]) - if fs:is_dir(path) do puts("touch: #{path}: is a directory\n") end + if fs:is_dir(path) do fail("touch: #{path}: is a directory\n") end else if fs:size(path) < 0 do fs:store(path, "") end end diff --git a/gils/tree.rv b/gils/tree.rv index cc41601..d1a6af6 100644 --- a/gils/tree.rv +++ b/gils/tree.rv @@ -21,8 +21,8 @@ end const context = env.ctx const target = if context.argv:len() > 1 expand_path(context.argv[1]) else wd.path -if (vfs_owns(target) and target != "/") do puts("tree: #{target}: virtual dir\n") end -else if (target != "/" and fs:is_dir(target) == :false) do puts("tree: #{target}: not a directory\n") end +if (vfs_owns(target) and target != "/") do fail("tree: #{target}: virtual dir\n") end +else if (target != "/" and fs:is_dir(target) == :false) do fail("tree: #{target}: not a directory\n") end else do puts("#{target}\n") tree_walk(target, "") @@ -1,11 +1,11 @@ # word count const context = env.ctx -if context.argv:len() < 2 do puts("usage: wc <path>\n") end +if context.argv:len() < 2 do fail("usage: wc <path>\n") end else do const path = expand_path(context.argv[1]) const size = fs:size(path) - if size < 0 do puts("wc: #{path}: no such file\n") end + if size < 0 do fail("wc: #{path}: no such file\n") end else do const contents = if size > 0 fs:read_bytes(path, 0, size) else "" let line_count = 0 |
