From 4af40b51273f445da90ee7a48a2410fd0590eaa4 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sat, 12 Oct 2024 15:59:01 +0200 Subject: [PATCH] fix `os.execute` implementation (#524) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Just forward the whole command to `sh -c`, so there's no need to muck around with escaping, and all KOReader's use-cases are supported (redirection, multiple commands, etc…). --- assets/android.lua | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/assets/android.lua b/assets/android.lua index dbf05d75c..5c52a94b6 100644 --- a/assets/android.lua +++ b/assets/android.lua @@ -2725,13 +2725,7 @@ local function run(android_app_state) os.execute = function(command) -- luacheck: ignore 122 if command == nil then return -1 end - local argv = {} - command:gsub("([^ ]+)", function(arg) - -- strip quotes around argument, since they are not necessary here - arg = arg:gsub('"(.*)"', "%1") -- strip double quotes - arg = arg:gsub("'(.*)'", "%1") -- strip single quotes - table.insert(argv, arg) - end) + local argv = {'sh', '-c', command} return android.execute(unpack(argv)) end