lua-users home
lua-l archive

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


On Thu, Jul 8, 2010 at 06:50, David Manura <dm.lua@math2.org> wrote:
> On Wed, Jul 7, 2010 at 4:58 AM, Alexander Gladysh <agladysh@gmail.com> wrote:

<...>

>  local t = sh "ls $.Q($path) | $.filter $f | grep ^sg.* | $.totable"

> giving the impression that Lua functions are executed just like shell
> commands but in effect those are really pseudo commands executed
> in-process (sort-of like how sh has built-in commands).

> However, what about simply this?

>  exec 'ls /dev | lua -e $Q(for line in io.stdin:lines(true) do
> io.stdout:write(line,line) end) | grep ^sg.*'

But I want a closure here! Spawning another Lua process is no fun.

> Other possibilities include the script passed to "lua -e" opening up a
> socket (lsocket) to the main script and filtering its I/O through
> that.  That may be another way to implement the bidirectional pipe in
> a cross platform way.

Yes, that is a good thing to keep in mind.

Alexander.