lua-users home
lua-l archive

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


On Tue, Dec 24, 2013 at 4:08 PM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
On a Linux system, I get:

$ lua
Lua 5.2.3  Copyright (C) 1994-2013 Lua.org, PUC-Rio
> ok,stream = pcall(io.popen,"unknown_program")
> sh: 1: unknown_program: not found
print(ok,stream)
true    file (0x9be9800)

I.e. I can't tell from the return values that the program was not found,
only from the message on stderr.

Checking that io.open works is no good either. If `unknown_program` exists
but is not executable, I still get true and a file, with error message
on stderr.

Workaround:

> prog="unknown_program"
> which = io.popen("which "..prog)
> if which:read() then stream=io.popen(prog) end

Am I missing something?


Isn't this expected since the the file handle (FD) is the pipe's?

  Eduardo