D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Shellwords
/
Filename :
cdesc-Shellwords.ri
back
Copy
U:RDoc::NormalModule[iI"Shellwords:ET@0o:RDoc::Markup::Document:@parts[o;;[$S:RDoc::Markup::Heading: leveli: textI"3Manipulates strings like the UNIX Bourne shell;To:RDoc::Markup::BlankLine o:RDoc::Markup::Paragraph;[I"IThis module manipulates strings according to the word parsing rules ;TI"of the UNIX Bourne shell.;T@o; ;[I"TThe <tt>shellwords()</tt> function was originally a port of shellwords.pl, but ;TI"\modified to conform to {the Shell & Utilities volume of the IEEE Std 1003.1-2008, 2016 ;TI"VEdition}[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/contents.html];T@S; ; i;I" Usage;T@o; ;[I"QYou can use Shellwords to parse a string into a Bourne shell friendly Array.;T@o:RDoc::Markup::Verbatim;[ I"require 'shellwords' ;TI" ;TI"3argv = Shellwords.split('three blind "mice"') ;TI")argv #=> ["three", "blind", "mice"] ;T:@format0o; ;[I"COnce you've required Shellwords, you can use the #split alias ;TI"String#shellsplit.;T@o;;[I"*argv = "see how they run".shellsplit ;TI",argv #=> ["see", "how", "they", "run"] ;T;0o; ;[I"IThey treat quotes as special characters, so an unmatched quote will ;TI"cause an ArgumentError.;T@o;;[I">argv = "they all ran after the farmer's wife".shellsplit ;TI"2 #=> ArgumentError: Unmatched quote: ... ;T;0o; ;[I"<Shellwords also provides methods that do the opposite. ;TI"BShellwords.escape, or its alias, String#shellescape, escapes ;TI"@shell metacharacters in a string for use in a command line.;T@o;;[ I" filename = "special's.txt" ;TI" ;TI".system("cat -- #{filename.shellescape}") ;TI"%# runs "cat -- special\\'s.txt" ;T;0o; ;[I"JNote the '--'. Without it, cat(1) will treat the following argument ;TI"Gas a command line option if it starts with '-'. It is guaranteed ;TI"Fthat Shellwords.escape converts a string to a form that a Bourne ;TI"Ashell will parse back to the original string, but it is the ;TI"Hprogrammer's responsibility to make sure that passing an arbitrary ;TI"(argument to a command does no harm.;T@o; ;[I"LShellwords also comes with a core extension for Array, Array#shelljoin.;T@o;;[ I"dir = "Funny GIFs" ;TI""argv = %W[ls -lta -- #{dir}] ;TI"(system(argv.shelljoin + " | less") ;TI"-# runs "ls -lta -- Funny\\ GIFs | less" ;T;0o; ;[I"HYou can use this method to build a complete command line out of an ;TI"array of arguments.;T@S; ; i;I"Authors;To:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0;[o; ;[I"Wakou Aoyama;To;;0;[o; ;[I"%Akinori MUSHA <knu@iDaemons.org>;T@S; ; i;I"Contact;To;;;;[o;;0;[o; ;[I":Akinori MUSHA <knu@iDaemons.org> (current maintainer);T: @fileI"lib/shellwords.rb;T:0@omit_headings_from_table_of_contents_below0;0;0[ [U:RDoc::Constant[i I"VERSION;TI"Shellwords::VERSION;T:public0o;;[o; ;[I"The version number string.;T;@j;0@j@cRDoc::NormalModule0[ [[I" class;T[[;[[I"escape;TI"lib/shellwords.rb;T[I" join;T@{[I"shellescape;T@{[I"shelljoin;T@{[I"shellsplit;T@{[I"shellwords;T@{[I" split;T@{[:protected[ [:private[ [I" instance;T[[;[ [;[ [;[ [@@{[@�@{[@�@{[@�@{[ [U:RDoc::Context::Section[i 0o;;[ ;0;0[@j@jcRDoc::TopLevel