mirror of
https://github.com/octoleo/lsyncd.git
synced 2024-12-12 14:17:47 +00:00
Add proper compatibilty wrappers for 5.1
This commit is contained in:
parent
63f506582a
commit
82f9f27172
17
lsyncd.lua
17
lsyncd.lua
@ -27,6 +27,15 @@ end
|
|||||||
|
|
||||||
lsyncd_version = '2.3.0-beta1'
|
lsyncd_version = '2.3.0-beta1'
|
||||||
|
|
||||||
|
-- compatibility with 5.1
|
||||||
|
if table.unpack == nil then
|
||||||
|
table.unpack = unpack
|
||||||
|
end
|
||||||
|
|
||||||
|
local lver = string.gmatch(_VERSION, "%w (%d).(%d)")
|
||||||
|
local _LUA_VERSION_MAJOR, _LUA_VERSION_MINOR = lver()
|
||||||
|
_LUA_VERSION_MAJOR = tonumber(_LUA_VERSION_MAJOR)
|
||||||
|
_LUA_VERSION_MINOR = tonumber(_LUA_VERSION_MINOR)
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Shortcuts (which user is supposed to be able to use them as well)
|
-- Shortcuts (which user is supposed to be able to use them as well)
|
||||||
@ -6043,8 +6052,12 @@ function runner.initialize( firstTime )
|
|||||||
if type(config[fn]) == 'string'
|
if type(config[fn]) == 'string'
|
||||||
then
|
then
|
||||||
local ft = functionWriter.translate( config[ fn ] )
|
local ft = functionWriter.translate( config[ fn ] )
|
||||||
|
if _LUA_VERSION_MAJOR <= 5 and _LUA_VERSION_MINOR < 2 then
|
||||||
config[ fn ] = assert( load( 'return '..ft ) )( )
|
-- lua 5.1 and older
|
||||||
|
config[ fn ] = assert( loadstring( 'return '..ft ) )( )
|
||||||
|
else
|
||||||
|
config[ fn ] = assert( load( 'return '..ft ) )( )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -37,7 +37,7 @@ posix.kill( pid )
|
|||||||
local _, exitmsg, lexitcode = posix.wait( lpid )
|
local _, exitmsg, lexitcode = posix.wait( lpid )
|
||||||
cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode )
|
cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode )
|
||||||
|
|
||||||
_, result, code = os.execute( 'diff -r ' .. srcdir .. ' ' .. trgdir )
|
result, code = execute( 'diff -r ' .. srcdir .. ' ' .. trgdir )
|
||||||
|
|
||||||
if result == 'exit'
|
if result == 'exit'
|
||||||
then
|
then
|
||||||
|
@ -39,7 +39,7 @@ posix.kill( pid )
|
|||||||
local _, exitmsg, lexitcode = posix.wait( lpid )
|
local _, exitmsg, lexitcode = posix.wait( lpid )
|
||||||
cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode )
|
cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode )
|
||||||
|
|
||||||
_, result, code = os.execute( 'diff -r ' .. srcdir .. ' ' .. trgdir )
|
result, code = execute( 'diff -r ' .. srcdir .. ' ' .. trgdir )
|
||||||
|
|
||||||
if result == 'exit'
|
if result == 'exit'
|
||||||
then
|
then
|
||||||
|
@ -47,7 +47,7 @@ local _, exitmsg, lexitcode = posix.wait( lpid )
|
|||||||
|
|
||||||
cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode )
|
cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode )
|
||||||
|
|
||||||
_, result, code = os.execute( 'diff -r ' .. srcdir .. ' ' .. trgdir )
|
result, code = execute( 'diff -r ' .. srcdir .. ' ' .. trgdir )
|
||||||
|
|
||||||
if result == 'exit'
|
if result == 'exit'
|
||||||
then
|
then
|
||||||
|
@ -115,7 +115,7 @@ cwriteln( 'waiting for Lsyncd to remove destination' )
|
|||||||
|
|
||||||
posix.sleep( 5 )
|
posix.sleep( 5 )
|
||||||
|
|
||||||
_, result, code = os.execute( 'diff -urN ' .. srcdir .. ' ' .. trgdir )
|
result, code = execute( 'diff -urN ' .. srcdir .. ' ' .. trgdir )
|
||||||
|
|
||||||
if result ~= 'exit' or code ~= 0
|
if result ~= 'exit' or code ~= 0
|
||||||
then
|
then
|
||||||
|
@ -113,7 +113,7 @@ os.execute( 'rm -rf ' .. srcdir .. '/*' )
|
|||||||
cwriteln( 'waiting for Lsyncd to remove destination' )
|
cwriteln( 'waiting for Lsyncd to remove destination' )
|
||||||
posix.sleep( 5 )
|
posix.sleep( 5 )
|
||||||
|
|
||||||
_, result, code = os.execute( 'diff -urN '..srcdir..' '..trgdir )
|
result, code = execute( 'diff -urN '..srcdir..' '..trgdir )
|
||||||
|
|
||||||
if result ~= 'exit' or code ~= 0
|
if result ~= 'exit' or code ~= 0
|
||||||
then
|
then
|
||||||
|
@ -109,7 +109,7 @@ cwriteln( 'waiting for Lsyncd to remove destination' )
|
|||||||
|
|
||||||
posix.sleep( 5 )
|
posix.sleep( 5 )
|
||||||
|
|
||||||
_, result, code = os.execute( 'diff -urN ' .. srcdir .. ' ' .. trgdir )
|
result, code = execute( 'diff -urN ' .. srcdir .. ' ' .. trgdir )
|
||||||
|
|
||||||
if result ~= 'exit' or code ~= 0
|
if result ~= 'exit' or code ~= 0
|
||||||
then
|
then
|
||||||
|
@ -60,7 +60,7 @@ cwriteln( 'Exitcode of Lsyncd = ', exitmsg, ' ', lexitcode)
|
|||||||
posix.sleep( 1 )
|
posix.sleep( 1 )
|
||||||
|
|
||||||
cwriteln( '* differences:' )
|
cwriteln( '* differences:' )
|
||||||
_, result, code = os.execute( 'diff -urN ' .. srcdir .. ' ' .. trgdir )
|
result, code = execute( 'diff -urN ' .. srcdir .. ' ' .. trgdir )
|
||||||
|
|
||||||
if result == 'exit'
|
if result == 'exit'
|
||||||
then
|
then
|
||||||
|
@ -9,6 +9,11 @@ local c1='\027[47;34m'
|
|||||||
|
|
||||||
local c0='\027[0m'
|
local c0='\027[0m'
|
||||||
|
|
||||||
|
-- compatibility with 5.1
|
||||||
|
if table.unpack == nil then
|
||||||
|
table.unpack = unpack
|
||||||
|
end
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Writes colorized.
|
-- Writes colorized.
|
||||||
--
|
--
|
||||||
@ -18,6 +23,23 @@ function cwriteln
|
|||||||
io.write( c0, '\n' )
|
io.write( c0, '\n' )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local lver = string.gmatch(_VERSION, "Lua (%d).(%d)")
|
||||||
|
_LUA_VERSION_MAJOR, _LUA_VERSION_MINOR = lver()
|
||||||
|
_LUA_VERSION_MAJOR = tonumber(_LUA_VERSION_MAJOR)
|
||||||
|
_LUA_VERSION_MINOR = tonumber(_LUA_VERSION_MINOR)
|
||||||
|
|
||||||
|
-- Compatibility execute function
|
||||||
|
function execute(...)
|
||||||
|
if _LUA_VERSION_MAJOR <= 5 and
|
||||||
|
_LUA_VERSION_MINOR < 2 then
|
||||||
|
local rv = os.execute(...)
|
||||||
|
return "exit", rv
|
||||||
|
else
|
||||||
|
local ok, why, code = os.execute(...)
|
||||||
|
return why, code
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Initializes the pseudo random generator
|
-- Initializes the pseudo random generator
|
||||||
--
|
--
|
||||||
|
Loading…
Reference in New Issue
Block a user