Skip to content

Commit

Permalink
fix os.execute implementation
Browse files Browse the repository at this point in the history
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…).
  • Loading branch information
benoit-pierre committed Oct 12, 2024
1 parent f6c01d3 commit 09ccffa
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions assets/android.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 09ccffa

Please sign in to comment.