From 1c7e81492d78b52bbe6c1bc25112874244858107 Mon Sep 17 00:00:00 2001 From: Leon Date: Sun, 14 Nov 2021 20:47:04 +0100 Subject: [PATCH] added example (currently with sideeffects) --- examples/helloshell.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 examples/helloshell.lua diff --git a/examples/helloshell.lua b/examples/helloshell.lua new file mode 100644 index 000000000..8f472bec7 --- /dev/null +++ b/examples/helloshell.lua @@ -0,0 +1,19 @@ +-- o/third_party/lua/lua.com helloshell.lua | sort | uniq +-- output: +-- 124060 +-- 130754 +-- 2924 +-- 2943 +-- 2944 + +function capture(cmd) + local f = io.popen(cmd,'r') + local s = f:read("*a") + f:close() + return s +end + +for i=1, 100 do + local stdout = capture('ls -laR / 2>&1') + print(stdout:len()) +end