Lignum

Batch Interpreter

Oct 11th, 2014
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.41 KB | None | 0 0
  1. local args = {...}
  2.  
  3. if #args == 0 then
  4.   printError("Usage: batch <file>")
  5.   return
  6. end
  7.  
  8. local f = args[1]
  9. local file = fs.open(f, "r")
  10. local line = file.readLine()
  11.  
  12. repeat
  13.   if line ~= nil then
  14.     local words = {}
  15.     for word in line:gmatch("%S+") do
  16.       table.insert(words, word)
  17.     end
  18.    
  19.     shell.run(unpack(words))
  20.   end
  21.  
  22.   line = file.readLine()
  23. until line == nil
  24.  
  25. file.close()
Advertisement
Add Comment
Please, Sign In to add comment