Implement `execute' action keyword
This commit is contained in:
parent
43e90dafce
commit
1e1645107c
9
features/actions/execute.feature
Normal file
9
features/actions/execute.feature
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
Feature: `execute' action keyword
|
||||||
|
|
||||||
|
Scenario: executes the given command in a shell with current standard output
|
||||||
|
Given uhwm is running with this run control file:
|
||||||
|
"""
|
||||||
|
key(:f) { execute 'echo etucexe_tset | rev' }
|
||||||
|
"""
|
||||||
|
When I press the alt+f keys
|
||||||
|
Then the output must contain "test_execute"
|
@ -12,6 +12,21 @@ module Uh
|
|||||||
def quit
|
def quit
|
||||||
@events.emit :quit
|
@events.emit :quit
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def execute command
|
||||||
|
@env.log "Execute: #{command}"
|
||||||
|
pid = fork do
|
||||||
|
fork do
|
||||||
|
Process.setsid
|
||||||
|
begin
|
||||||
|
exec command
|
||||||
|
rescue Errno::ENOENT => e
|
||||||
|
@env.log_error "ExecuteError: #{e}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Process.waitpid pid
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user