Skip to content

Instantly share code, notes, and snippets.

@johnl
Created September 17, 2013 10:06
Show Gist options
  • Save johnl/6592391 to your computer and use it in GitHub Desktop.
Save johnl/6592391 to your computer and use it in GitHub Desktop.
ruby shellwords library examples
irb(main):001:0> require 'shellwords'
=> true
irb(main):002:0> 'once upon "a time" there was\ a\ giant'.shellsplit
=> ["once", "upon", "a time", "there", "was a giant"]
irb(main):003:0> puts "one upon a time there was a giant & 'her dog' `hack`".shellescape
one\ upon\ a\ time\ there\ was\ a\ giant\ \&\ \'her\ dog\'\ \`hack\`
irb(main):004:0> ["ls", "/home/john/secret stuff/"].shelljoin
=> "ls /home/john/secret\\ stuff/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment