P.S. Why not use a table of functions? local action = { Linux = function() print "Using Linux" end, Darwin = function() print "Using Darwin" end, -- ... } local fd = assert(io.popen("uname")) local os = assert(fd:read()) fd:close() action[os]()