Skip to content

Commit

Permalink
fix os.execute implementation (#524)
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 authored Oct 12, 2024
1 parent f6c01d3 commit 4af40b5
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 4af40b5

Please sign in to comment.