From: Jagadeesh Date: 2009-05-26T00:45:32+09:00 Subject: Re: String concatenation in Ruby On May 25, 4:44 pm, Robert Klemme wrote: > 2009/5/25 Bertram Scharpf : > > > > > Hi, > > > Am Montag, 25. Mai 2009, 17:30:43 +0900 schrieb Robert Klemme: > >> 2009/5/25 Mohit Sindhwani : > >> > Jagadeesh wrote: > >> >> [sample perl code] > >> >> $CMD = join('  ',  $cmd, $arg1, $arg2, $arg3); > > >> > Not 100% sure of what you need, but I think this will do the job for you: > >> > str = [cmd, arg1, arg2, arg3].join(' ') > > >> If this is for executing an external process, there is no need to lump > >> all these together, instead you can do which has the advantage that > >> you do not need a shell to parse the individual arguments and also > >> whitespace cannot cause trouble. > > >> system cmd, arg1, arg2, arg3 > > > There are two more advantages: Arguments that contain spaces > > remain one argument. > > That's what I meant (see above). > > > Arguments that contain shell operators like > > ; && || `...` could produce malicious side effects. > > Hehe, true! > > > Another approach: > > >  args = [ arg1, arg2, arg3] > >  system cmd, *args > > What advantage would it have to first create that array 'args'? Well this approach also look neat and readable. Thanks