lua-users home
lua-l archive

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

> > io.popen('lua.exe -e"print(string.char(49,26,50))"',
> "rb"):read"*a":byte(1,-1)
> stdin:1: bad argument #2 to 'popen' (invalid mode)
> [...]
> Why does Lua 5.4 not allow me to read verbatim output of an external
> Windows process?

According to the official documentation [1]:

  . The character string mode specifies the type of access requested,
    as follows.

    Access mode 	Description

    "r" 	The calling process can read the spawned command's
                standard output using the returned stream.
    "w" 	The calling process can write to the spawned command's
                standard input using the returned stream.
    "b" 	Open in binary mode.
    "t" 	Open in text mode.

Note that the string "rb" is not in the list. :-)

More seriously, we really don't know the meaning of the above
documentation, and therefore we don't know what to implement.
(Maybe they mean "[rw][bt]?", but that is just speculation.)

For now, you can compile Lua defining l_checkmode(x) as 1 or
whatever you seem fit.


-- Roberto