Skip to content

Commit

Permalink
Add back my original example of Shellwords#shellescape.
Browse files Browse the repository at this point in the history
* lib/shellwords.rb (Shellwords#shellescape): Add back my original
  real world example with some enhancement.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37577 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
knu committed Nov 9, 2012
1 parent eccb955 commit ab714c8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Fri Nov 9 15:13:16 2012 Akinori MUSHA <[email protected]>
Fri Nov 9 15:25:42 2012 Akinori MUSHA <[email protected]>

* lib/shellwords.rb (Shellwords#shellescape): Undo part of the
* lib/shellwords.rb (Shellwords#shellescape): Add back my original
real world example with some enhancement.

* lib/shellwords.rb (Shellwords#shelljoin): Undo part of the
previous rdoc change. This new example using a string-only
array was not in line with the description.

Expand Down
9 changes: 9 additions & 0 deletions lib/shellwords.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ class << self
# argv = "It's better to give than to receive".shellescape
# argv #=> "It\\'s\\ better\\ to\\ give\\ than\\ to\\ receive"
#
# # Search files in lib for method definitions
# pattern = "^[ \t]*def "
# open("| grep -Ern #{pattern.shellescape} lib") { |grep|
# grep.each_line { |line|
# file, lineno, matched_line = line.split(':', 3)
# # ...
# }
# }
#
# It is the caller's responsibility to encode the string in the right
# encoding for the shell environment where this string is used.
#
Expand Down

0 comments on commit ab714c8

Please sign in to comment.