From: Robert Klemme Date: 2011-03-02T22:45:18+09:00 Subject: Re: exec using sh -c or directly running the command, depending on the system On Wed, Mar 2, 2011 at 2:29 PM, Xavier Noëlle wrote: > 2011/3/2 Brian Candler : >> Looks like there was a change in Ruby, where perhaps it now does an >> optimisation to check for cases where a shell isn't required (e.g. no >> pipelines or redirection) > > That's what I noticed with quoting, but I never managed to take > advantage of this feature. > Well, more precisely, I tried to cheat Ruby by quoting every command > line argument, which works on a system, but not the others (don't know > if it's a matter of version, system, or something else). What works is > to append a fake redirection to the command itself, but it's...ugly ^^ > >> You could make it consistent by using the multi-argument form of exec, >> which I believe will bypass the shell in all cases: > > Works in this case, thanks ! > > What about the case in which a shell is needed ? Is there a way to > force Ruby to use a subshell instead of doing everything by itself ? You can always explicitly invoke the shell. ruby19 -e 'exec(ENV["SHELL"], "-c", "whatever you like") Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/