[latex3-commits] [git/LaTeX3-latex3-l3build] master: refactor popen() into separate function (b5aa3f2)
Will Robertson
wspr81 at gmail.com
Mon Jan 7 14:28:56 CET 2019
Repository : https://github.com/latex3/l3build
On branch : master
Link : https://github.com/latex3/l3build/commit/b5aa3f20fc1f0db8cc4faddafb0ffc695868ee76
>---------------------------------------------------------------
commit b5aa3f20fc1f0db8cc4faddafb0ffc695868ee76
Author: Will Robertson <wspr81 at gmail.com>
Date: Mon Jan 7 21:28:56 2019 +0800
refactor popen() into separate function
>---------------------------------------------------------------
b5aa3f20fc1f0db8cc4faddafb0ffc695868ee76
l3build-upload.lua | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/l3build-upload.lua b/l3build-upload.lua
index 13f0841..b54bac6 100644
--- a/l3build-upload.lua
+++ b/l3build-upload.lua
@@ -120,9 +120,7 @@ function upload(tagnames)
-- use popen not execute so get the return body local exit_status=os.execute(ctan_post .. "validate")
if (curl_debug==false) then
print("Contacting CTAN for validation:")
- local fp = assert(popen(ctan_post .. "validate", 'r'))
- fp_return = assert(fp:read('*a'))
- fp:close()
+ fp_return = shell(ctan_post .. "validate")
else
fp_return="WARNING: curl_debug==true: posting disabled"
print(ctan_post)
@@ -133,9 +131,7 @@ function upload(tagnames)
print("Package not found on CTAN; re-validating as new package:")
uploadconfig.update = false
ctan_post = construct_ctan_post(uploadfile)
- local fp = assert(popen(ctan_post .. "validate", 'r'))
- fp_return = assert(fp:read('*a'))
- fp:close()
+ fp_return = shell(ctan_post .. "validate")
end
end
if match(fp_return,"WARNING") or match(fp_return,"ERROR") then
@@ -155,9 +151,7 @@ function upload(tagnames)
end
end
if (ctanupload==true) then
- local fp = assert(popen(ctan_post .. "upload", 'r'))
- fp_return = assert(fp:read('*a'))
- fp:close()
+ fp_return = shell(ctan_post .. "upload")
-- this is just html, could save to a file
-- or echo a cleaned up version
print('Response from CTAN:')
@@ -180,6 +174,13 @@ function trim_space(s)
end
+function shell(s)
+ local h = assert(popen(s, 'r'))
+ t = assert(h:read('*a'))
+ h:close()
+ return t
+end
+
function construct_ctan_post(uploadfile)
-- start building the curl command:
More information about the latex3-commits
mailing list