lua-users home
lua-l archive

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


You're right. I've missed that, sorry :-)

However, I'd use a clean table for this. Peter's one still prone to
name clashes, I think.

Yeah, the functions defined in the module can shadow external commands and the global "shell" might collide with another variable. I consider both bad style, however in my defence the module is meant to be used from simple and short shell scripts so I took some short cuts :-)

Regarding the global variable the fix is simple of course: just prefix the first line of the module with "local". The reason I didn't do this is that I don't use the "local" keyword in my shell scripts unless I actually need it and then the following seems out of place:

	local shell = require 'shell'

Actually I've never liked the "local m = require 'm'" idiom because I almost never need the flexibility of using different names for the local variable and the module name.

 - Peter Odding