lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Wouldn't be easier to use the "simple I/O model"?

- local infile, err = io.open(arg[1], "r")
- if not infile then
-         io.stderr:write(err, "\n")
-         return
- end
+ io.input(arg[1])

-        outfile, err = io.open(arg[2], "w")
-        if not outfile then
-                infile:close()
-                io.stderr:write(err, "\n")
-                return
-        end
+        io.output(arg[2])

-        (outfile or io.stdout):write(line, "\n")
+        io.write(line, "\n")

(etc.)

-- Roberto