How do you construct a read-write pipe with lua?

后端 未结 7 1135
甜味超标
甜味超标 2020-12-09 04:26

I\'d like to do the equivalent of:

foo=$(echo \"$foo\"|someprogram)

within lua -- ie, I\'ve got a variable containing a bunch of text, and

7条回答
  •  醉酒成梦
    2020-12-09 05:00

    A not very nice solution that avoids a temporary file...

    require("io")
    require("posix")
    
    x="hello\nworld"
    
    posix.setenv("LUA_X",x)
    i=popen('echo "$LUA_X" | myfilter')
    x=i.read("*a")
    

提交回复
热议问题