7878
7979local function dir (folder )
8080 -- we will have to get the current dir later (we will need fs.resolve!)
81- folder = " / " .. (folder or " " )
81+ folder = (folder or " " )
8282 -- is it a directory?
8383 if not fs .isDirectory (folder ) then print (" No such folder." ) return end
8484 -- if it is we start...
@@ -95,8 +95,9 @@ local function moveFile(from, to, force)
9595 checkArg (1 , from , " string" )
9696 checkArg (2 , to , " string" )
9797 if fs .isDirectory (to ) then
98+ if not fs .name then error (" Need to specify name for destination!" , 0 ) end
9899 to = to .. " /" .. fs .name (from )
99- end
100+ end
100101 if fs .exists (to ) then
101102 if not force then
102103 printErr (" target file exists" )
@@ -114,8 +115,9 @@ local function copyFile(from, to, force)
114115 checkArg (1 , from , " string" )
115116 checkArg (2 , to , " string" )
116117 if fs .isDirectory (to ) then
118+ if not fs .name then error (" Need to specify name for destination!" , 0 ) end
117119 to = to .. " /" .. fs .name (from )
118- end
120+ end
119121 if fs .exists (to ) then
120122 if not force then
121123 printErr (" target file exists" )
@@ -190,7 +192,7 @@ local function runline(line)
190192 if command == " echo" then print (table.concat (parts , " " , 2 )) return true end
191193 if command == " print" then print (table.concat (parts , " \t " , 2 )) return true end
192194 if command == " touch" then filesystem .close (filesystem .open (fixPath (parts [2 ]), ' w' )) return true end
193- if command == " del" then filesystem .remove (fixPath (parts [2 ])) return true end
195+ if command == " del" then if filesystem .remove (fixPath (parts [2 ])) then return true else error ( " Can't delete! " , 0 ) end end
194196 if command == " copy" then return twoFileCommandHelper (copyFile , parts ) end
195197 if command == " rename" then return twoFileCommandHelper (moveFile , parts ) end
196198 if command == " ren" then return twoFileCommandHelper (moveFile , parts ) end
@@ -237,5 +239,5 @@ while true do
237239 while # history > 10 do
238240 table.remove (history , 1 )
239241 end
240- if shell .runline (line ) == " exit" then return end
241- end
242+ if shell .runline (line ) == " exit" then return true end
243+ end
0 commit comments