luvit/luvit

Luvit's global ``print`` replacement (from ``deps/pretty-print``) fails when trying to pipe the output on Windows

Duckwhale opened this issue · 0 comments

Example code:

print("Hello world")

Running it with luvit test.lua works, but when trying to re-route the output via luvit test.lua > test.log it fails:

image

Expected behavior:

  • No console output (as STDIN should be re-routed to the file)
  • test.log contains the text "Hello world"

Actual behavior:

  • The above console output
  • test.log is empty

Additional information:

  • This appears to be independent of the terminal used; I tried it with both the default cmd and my usual Cmder shell.
  • When trying luvit test.lua | tee test.log it does work as expected (tee is included in cmder/cygwin, not cmd)
  • In fact, even luvit test.lua | test.log seems to work without errors, though it opens the editor window afterwards

Relevant code:

if uv.guess_handle(uv.fileno(fs))=='tty' then