-- This assumes that os.getcwd() returns the path to the main pc-lint directory. pathToPcLintBin = os.getcwd() .. "/bin/" -- Defines for pc-lint. -- This should be sent as a table argument to getPcLintCommands(). I'm leaving that to the reader. definesPcLint = { 'YOUR_DEFINES=1', 'nullptr=0' } -- Returns the pc-lint commands to lint files. -- Pass a table with the files to lint. The paths must be absolute. function getPcLintCommands(fileList) -- Pc-lint is only supported on Windows. assert(os.get() == "windows", "Pc-lint is only supported on Windows.") -- Make sure that it is a table. assert(type(fileList) == "table", "Invalid argument type. It must be a table.") -- Make sure that the table is not empty. assert(#fileList ~= 0, "The table of files is empty.") local pclintCommands = '' -- Get the include dirs table. includeDirsList = configuration().includedirs -- Loop on every file in the file list and make a command for pc-lint. for _, filename in ipairs(fileList) do pclintCommands = pclintCommands .. pathToPcLintBin .. 'LINT-NT.EXE -i\"' .. pathToPcLintBin .. '\" std.lnt -u -b' -- Add defines. for _, defineEntry in ipairs(definesPcLint) do pclintCommands = pclintCommands .. ' -d\"' .. defineEntry .. '\"' end -- Add include paths. for _, includepath in ipairs(includeDirsList) do pclintCommands = pclintCommands .. ' -i\"' .. includepath .. '\"' end -- Add the file to lint and stop the command if it fails. pclintCommands = pclintCommands .. ' \"' .. path.getabsolute(filename) .. '\"\nif errorlevel 1 goto :VCEnd\n' end return pclintCommands end

Please keep in mind that I'm new to Lua so if anybody can improve this script, please do.
Thanks.
1. Parentheses after if are redundant, e.g. you can write
(Although you might want to make code look like C...)
2. If
, than its type is "nil", not "table", so this condition is redundant.
3.
doesn't feel right, I'd rather checked #fileList == 0 (# returns size of table)
4. Seems like
and
just protect from incorrect use of function in project file. You can use assert(), it will stop execution on error instead of silent return.
5. I think it would be better if this function just returned pclintCommand, and then used e.g. the next way
It would be more obvious what's going on, you also will be able to cache return value if needed.
6. You can use _ as name of dummy indices instead of i or j.
Great! I didn't know Lua had asserts. I will update the script later today when I get home.
Thanks.
I just updated the script on the first post.
To improve performance you can accumulate components of pclintCommands in a table, an then produce final string with table.concat. Lua creates new string for every concatenation, so your code can produce a lot of temporary objects.
I woulnd't check for Windows with assert, it would be nicer to just return nil or empty string on other platforms.