[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: io.popen of unknown program succeeds
- From: Dirk Laurie <dirk.laurie@...>
- Date: Tue, 24 Dec 2013 10:08:23 +0200
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?