隱藏功能 |
|
自 5.1.3 起,由於可能會產生 bug,所以不允許關閉標準檔案(例如 stdin、stdout 與 stderr)[1][5]
> assert(io.stdout:close()) stdin:1: cannot close standard file
以下為一個應謹慎使用的方法
local f = assert(io.open '/dev/null') -- or possibly NUL on Windows debug.setfenv(io.stdout, debug.getfenv(f)) f:close() assert(io.stdout:close()) -- ok