Exit_0

A simple method that raises Exit_0::Non_0 if $?.exitstatus is not 0.

Don't like Exit_0? Try:

Windows

Use something else. Check the previous list above for other alternatives, especialy POpen4, which is Windows and POSIX compatible.

Implementation

Exit_0 runs your command through bash:

Exit_0 "
  cd ~/
  pwd
"

# --> Your command is processed as:
str = str.split("\n").map(:strip).map(&:reject).join('&&')
"bash -lc #{str.inspect}"

Exit_0 lives in one file. So if you have any questions, here it is.

Installation

gem install Exit_0

Usage

require "Exit_0"

Exit_0 'uptime'
Exit_0 'ls', :input=>' /some/dir '
Exit_0 { system "uptime" }

# The following raises an error.
Exit_0 'uptimeSS'
Exit_0 { `uptimeSSS` }

# Exit_0 and Exit_0 are the same.
Exit_0 'uptime'
Exit_0 'grep a', :input=>"a \n b \n c"

# Get results from standard output, standard error.
Exit_0('uptime').out      # String is stripped.
Exit_0('uptimeSS').err    # String is stripped.

Exit_0('uptime').raw_out  # Raw string, no :strip used.
Exit_0('uptime').raw_err  # Raw string, no :strip used.

Run Tests

git clone git@github.com:da99/Exit_0.git
cd Exit_0
bundle update
bundle exec bacon spec/main.rb

"I hate writing."

If you know of existing software that makes the above redundant, please tell me. The last thing I want to do is maintain code.