Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

subshell

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

subshell

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Subshell

This gem makes it easy to run shell commands from within ruby. It will raise an exception if the command fails with an unexpected exit status. By default it automatically redirects STDERR to STDOUT when executing the command. The return value is the output of the command with whitespace automatically stripped.

Example usage:

Subshell.exec 'echo hello world'                          # => "hello world"
Subshell.exec 'echo hello world', strip_whitespace: false # => "hello world\n"
Subshell.exec 'exit 1'                                    # => raises RuntimeError

Options

OptionDefaultDescription
redirect_stderr_to_stdouttrueappend 2>&1 to the command
expected_status0raise if the exit status of the command does not equal this value
strip_whitespacetruestrip whitespace from the command's output
loggerRails logger (if available) or nillog debug info, if set
debugfalseprint debug info to STDOUT. does not affect logger output
quietfalsedisable logger and STDOUT logging. useful to suppress sensitive or verbose data from being logged

These options can be set per call. For convenience, the defaults can be changed with a call to Subshell.set_defaults:

Subshell.set_defaults(strip_whitespace: false)
Subshell.exec 'echo hello world'                 # => 'hello world\n'

Installation

Add this line to your application's Gemfile:

gem 'subshell'

And then execute:

$ bundle

Or install it yourself as:

$ gem install subshell

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/falconed/subshell. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 19 Oct 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc