perl -pe "s/\Q _hx_bit_raw = _G.require('bit32')/\E _hx_bit_raw = {arshift = function(x, n) local y = x >> n; if (x < 0) then y = y | ~(-1 >> n) end return y end, band = function(x, y) return x & y end, bor = function(x, y) return x | y end, bnot = function(x) return ~x end, bxor = function(x, y) return x ~ y end, lshift = function(x, n) return x << n end, rshift = function(x, n) return x >> n end}/" -i $path
perl -pe 's/\Q__lua_lib_luautf8_Utf8 = _G.require("lua-utf8")/\E__lua_lib_luautf8_Utf8 = {byte = _G.string.byte, find = _G.string.find, gmatch = _G.string.gmatch, gsub = _G.string.gsub, lower = _G.string.lower, match = _G.string.match, reverse = _G.string.reverse, sub = _G.string.sub, upper = _G.string.upper}; for k, v in pairs(_G.utf8) do __lua_lib_luautf8_Utf8[k] = v end;/' -i $path
perl -pe 's/\Q_G.xpcall(Main.main, _hx_error)/\Elocal err; if not xpcall(Main.main, function(obj) err = ""; local _print = _G.print; _G.print = function(...) local args = table.pack(...) for i = 1, args.n do args[i] = tostring(args[i]) end err = err .. table.concat(args, "\\t") .. "\\n" end _hx_error(obj); _G.print = _print end) then _G.error(err) return end;/' -i $path