Sheller offers a unified interface for Ruby interaction with the shell environment and seeks to ease a few common pains.
- Easy access to STDOUT, STDERR, and exit status
- Execution with shell-safe quoting
- Exciting pipe operators
- Shell-safe quotation helpers to use however you like
> require 'sheller'
> Sheller.execute('cat', '/usr/share/dict/propernames').stdout.shuffle[0..5]
=> ["Dennis", "Turkeer", "Ahmed", "Rob", "Spyros", "Mott"]
> Sheller.execute('grep', '*', 'foo').stderr
=> "grep: foo: No such file or directory\n"
> Sheller.execute('date', '-r', 'ten').exit_status.to_i
=> 256
Sheller.execute('convert',
attachment.filename,
'--resize', '10x10',
thumbnail_filename)
Sheller.execute('cal', :|, 'grep', 9) # Pipe with the symbol :|
Sheller.execute('echo', 'Frogs', :>, 'frogs.txt') # Redirect with the symbol :>
Sheller.execute('find', '/',
'-name', filename,
:'2>&1')
Or use these more recognizable names
Sheller.execute('find', '/',
'-name', filename,
Sheller::STDERR_TO_STDOUT)
> Sheller.quote('echo')
=> "'echo'"
> Sheller.quote('~/private/My "so-called" friends')
=> "'~/private/My \"so-called\" friends'"