shelljoin(array)
Class Public methods
Builds a command line string from an argument list, array
.
All elements are joined into a single string with fields separated by a
space, where each element is escaped for Bourne shell and stringified using
to_s
.
1 2 3 | ary = [ "There's" , "a" , "time" , "and" , "place" , "for" , "everything" ] argv = Shellwords.join(ary) argv #=> "There\\'s a time and place for everything" |
Array#shelljoin is a shortcut for this function.
1 2 3 | ary = [ "Don't" , "rock" , "the" , "boat" ] argv = ary.shelljoin argv #=> "Don\\'t rock the boat" |
You can also mix non-string objects in the elements as allowed in Array#join.
1 | output = ` #{['ps', '-p', $$].shelljoin}` |
Please login to continue.