Implement `execute' action keyword

This commit is contained in:
Thibault Jouan 2015-04-16 17:12:00 +00:00
parent 43e90dafce
commit 1e1645107c
2 changed files with 24 additions and 0 deletions

View 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"

View File

@ -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