-{ extension 'xloop' }
-ls = io.popen ( (os.getenv("OS") or "") :match "^Windows" and "dir /b" or "ls")
+LS_COMMANDS = { "ls", "dir /b" }
+for i, cmd in ipairs(LS_COMMANDS) do
+ local f = io.popen (cmd)
+ ls = f :read '*a'
+ f :close()
+ if ls ~= '' then
+ break
+ elseif i == #LS_COMMANDS then
+ error "Can't figure out how to list files on your OS"
+ end
+end
+
this_script = arg[1]
local errors = {}
-for filename in ls :lines() if filename ~= this_script and filename :strmatch "%.m?lua$" do
+for filename in ls :gmatch "[^\n]+" if filename ~= this_script and filename :strmatch "%.m?lua$" do
printf ("*** running %s ***", filename)
local ret = os.execute ("metalua "..filename)
if ret ~= 0 then
end
end
-ls :close()
-
if #errors > 0 then
print("\n\n================================================================================")
error(