hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/gils/mv.rv
diff options
context:
space:
mode:
Diffstat (limited to 'gils/mv.rv')
-rw-r--r--gils/mv.rv18
1 files changed, 12 insertions, 6 deletions
diff --git a/gils/mv.rv b/gils/mv.rv
index b44995b..d44b898 100644
--- a/gils/mv.rv
+++ b/gils/mv.rv
@@ -1,14 +1,20 @@
# move or rename a file
const context = env.ctx
-if context.argv:len() < 3 do fail("usage: mv <source> <destination>\n") end
-else do
+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 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
+
+ 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
end
end