1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/shellwords.rb: Fix rdoc markups.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34286 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
knu 2012-01-12 18:49:27 +00:00
parent 8c72fc9bf0
commit c100aeb838
2 changed files with 10 additions and 17 deletions

View file

@ -1,3 +1,7 @@
Fri Jan 13 03:46:53 2012 Akinori MUSHA <knu@iDaemons.org>
* lib/shellwords.rb: Fix rdoc markups.
Fri Jan 13 03:38:36 2012 Akinori MUSHA <knu@iDaemons.org> Fri Jan 13 03:38:36 2012 Akinori MUSHA <knu@iDaemons.org>
* lib/shellwords.rb (Shellwords#shellsplit): Fix a bug where * lib/shellwords.rb (Shellwords#shellsplit): Fix a bug where

View file

@ -23,18 +23,16 @@
# * Akinori MUSHA <knu@iDaemons.org> (current maintainer) # * Akinori MUSHA <knu@iDaemons.org> (current maintainer)
module Shellwords module Shellwords
#
# Splits a string into an array of tokens in the same way the UNIX # Splits a string into an array of tokens in the same way the UNIX
# Bourne shell does. # Bourne shell does.
# #
# argv = Shellwords.split('here are "two words"') # argv = Shellwords.split('here are "two words"')
# argv #=> ["here", "are", "two words"] # argv #=> ["here", "are", "two words"]
# #
# +String#shellsplit+ is a shorthand for this function. # String#shellsplit is a shorthand for this function.
# #
# argv = 'here are "two words"'.shellsplit # argv = 'here are "two words"'.shellsplit
# argv #=> ["here", "are", "two words"] # argv #=> ["here", "are", "two words"]
#
def shellsplit(line) def shellsplit(line)
words = [] words = []
field = '' field = ''
@ -58,7 +56,6 @@ module Shellwords
alias split shellsplit alias split shellsplit
end end
#
# Escapes a string so that it can be safely used in a Bourne shell # Escapes a string so that it can be safely used in a Bourne shell
# command line. # command line.
# #
@ -69,7 +66,7 @@ module Shellwords
# # ... # # ...
# } # }
# #
# +String#shellescape+ is a shorthand for this function. # String#shellescape is a shorthand for this function.
# #
# open("| grep #{pattern.shellescape} file") { |pipe| # open("| grep #{pattern.shellescape} file") { |pipe|
# # ... # # ...
@ -79,7 +76,6 @@ module Shellwords
# encoding for the shell environment where this string is used. # encoding for the shell environment where this string is used.
# Multibyte characters are treated as multibyte characters, not # Multibyte characters are treated as multibyte characters, not
# bytes. # bytes.
#
def shellescape(str) def shellescape(str)
# An empty argument will be skipped, so return empty quotes. # An empty argument will be skipped, so return empty quotes.
return "''" if str.empty? return "''" if str.empty?
@ -104,7 +100,6 @@ module Shellwords
alias escape shellescape alias escape shellescape
end end
#
# Builds a command line string from an argument list +array+ joining # Builds a command line string from an argument list +array+ joining
# all elements escaped for Bourne shell and separated by a space. # all elements escaped for Bourne shell and separated by a space.
# #
@ -112,7 +107,7 @@ module Shellwords
# # ... # # ...
# } # }
# #
# +Array#shelljoin+ is a shorthand for this function. # Array#shelljoin is a shorthand for this function.
# #
# open('|' + ['grep', pattern, *files].shelljoin) { |pipe| # open('|' + ['grep', pattern, *files].shelljoin) { |pipe|
# # ... # # ...
@ -130,38 +125,32 @@ module Shellwords
end end
class String class String
#
# call-seq: # call-seq:
# str.shellsplit => array # str.shellsplit => array
# #
# Splits +str+ into an array of tokens in the same way the UNIX # Splits +str+ into an array of tokens in the same way the UNIX
# Bourne shell does. See +Shellwords::shellsplit+ for details. # Bourne shell does. See Shellwords::shellsplit for details.
#
def shellsplit def shellsplit
Shellwords.split(self) Shellwords.split(self)
end end
#
# call-seq: # call-seq:
# str.shellescape => string # str.shellescape => string
# #
# Escapes +str+ so that it can be safely used in a Bourne shell # Escapes +str+ so that it can be safely used in a Bourne shell
# command line. See +Shellwords::shellescape+ for details. # command line. See Shellwords::shellescape for details.
#
def shellescape def shellescape
Shellwords.escape(self) Shellwords.escape(self)
end end
end end
class Array class Array
#
# call-seq: # call-seq:
# array.shelljoin => string # array.shelljoin => string
# #
# Builds a command line string from an argument list +array+ joining # Builds a command line string from an argument list +array+ joining
# all elements escaped for Bourne shell and separated by a space. # all elements escaped for Bourne shell and separated by a space.
# See +Shellwords::shelljoin+ for details. # See Shellwords::shelljoin for details.
#
def shelljoin def shelljoin
Shellwords.join(self) Shellwords.join(self)
end end