1 --[[ For now, this sample function will simply record all the commands executed ]]--
3 function cmd1(name
, args
)
4 os
.execute('mkdir -p /tmp/debug')
5 local f
= io
.open('/tmp/debug/22', 'a')
6 f
:write("Command executed: " .. name
)
8 for i
, c
in pairs(args
) do
17 function cmd2(name
, args
)
18 os
.execute('mkdir -p /tmp/debug')
19 local f
= io
.open('/tmp/debug/11', 'a')
20 f
:write("Command executed: " .. name
)
22 for i
, c
in pairs(args
) do
31 ticket1
= screen
.hook("cmdexecuted", cmd1
)
32 ticket2
= screen
.hook("cmdexecuted", "cmd2")
35 if ticket1
~= nil then
36 screen
.unhook(ticket1
, cmd1
)
40 if ticket2
~= nil then
41 screen
.unhook(ticket2
, "cmd2")
46 --A second unhook should faild
47 function debug_unhook()
48 if screen
.unhook(ticket1
, "cmd1") == false then
49 error("unhook failed")
53 --A second hook should faild
55 ticket1
=screen
.hook("cmdexecuted", "cmd1")