lua-users home
lua-l archive

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


liolib.c ( line 57)
#define l_checkmodep(m) ((m[0] == 'r' || m[0] == 'w') && (m[1] == '\0' || m[1] == 'b'))

regards,
Ranier Vilela

Em seg., 30 de nov. de 2020 às 02:23, Egor Skriptunoff <egor.skriptunoff@gmail.com> escreveu:
Hi!
 
With Lua 5.4 some of my old scripts stop working due to io.popen() refusing to support binary reading mode on Windows.
 
This is an example to illustrate the problem:
 
Lua 5.3.4  Copyright (C) 1994-2017 Lua.org, PUC-Rio
> io.popen('lua.exe -e"print(string.char(49,26,50))"', "r"):read"*a":byte(1,-1)
49
> io.popen('lua.exe -e"print(string.char(49,26,50))"', "rb"):read"*a":byte(1,-1)
49      26      50      13      10
 
Lua 5.4.2  Copyright (C) 1994-2020 Lua.org, PUC-Rio
> io.popen('lua.exe -e"print(string.char(49,26,50))"', "r"):read"*a":byte(1,-1)
49
> 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)
stack traceback:
        [C]: in function 'io.popen'
        stdin:1: in main chunk
        [C]: in ?
 
Why does Lua 5.4 not allow me to read verbatim output of an external Windows process?