News for hackers. Stuff that matters.
Re:Zsh is your friend. by andrewflnr on Tuesday January 31, 2012 @12:37PM (#3534255)
Do you have to do anything weird to Lua to make it work as a system scripting language? Do you just use the built in OS interfaces?
Re:Zsh is your friend. by ramLlama on Tuesday January 31, 2012 @12:59PM (#3534349)
Yes, I just use the builtin's. Basically os.execute, and io.popen.

Popen is not the greatest because you can't get exit statuses from it. But for a quick script that is too messy in shell, it suffices. I believe that there is an extension to lua that has a popen that returns exit statuses. That can be used too.

For pattern matching, I either pipe to perl and capture the output, or use the inbuilt pattern matching system. It's surprisingly powerful.

Re:Zsh is your friend. by xolox on Tuesday January 31, 2012 @04:21PM (#3535260)
Since Lua 5.2 (just released) the pipe:close() method returns the exit status of the command. For more information see http://www.lua.org/manual/5.2/manual.html#pdf-file:close

You can also get the exit status using Lua 5.1 but it's definitely nasty (io.popen('your-command; echo $?') and the last line of output is the exit status).