“...I've been working since 2008 with Ruby / Ruby on Rails, love a bit of Elixir / Phoenix and learning Rust. I also poke through other people's code and make PRs for OpenSource Ruby projects that sometimes make it. Currently working for InPay...”

Rob Lacey (contact@robl.me)
Senior Software Engineer, Brighton, UK

capturing the exit status of a system call

Nice little snippet I came across today. The next time I execute a script I can establish the result without having to parse the stdout or stderr.

>> %x{echo "Hello World"}
=> "Hello World\n"
>> $?
=> #<Process::Status: pid=949,exited(0)>
>> $?.exitstatus
=> 0
>> %x{ /etc/init.d/apache2 restart }
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
=> " * Restarting web server apache2\n   ...fail!\n"
>> $?
=> #<Process::Status: pid=2016,exited(1)>
>> $?.exitstatus
=> 1