lua-users home
lua-l archive

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


As a quick hack I've done:

local path = os.getenv('PATH')
if path:find('C:\\Program') then
    windows = true
else
    windows = false
end

There are surely better strings for discrimination.

-- e

On Fri, Sep 26, 2014 at 4:06 AM, Enrico Colombini <erix@erix.it> wrote:
Does anybody have a recipe for recognizing that a Lua program is being executed under Windows?

Reading the "OS" environment variable does not work before Windows NT (I'm a perfectionist...).

I could open a file in 'w' mode, write a newline, close the file, read it back in 'wb' mode and check for \r\n. Requires write access, however.

Hmm... maybe I could check if arg[-1] starts with '%a%:' and/or if it contains a backslash. Would that be reliable?

--
  Enrico