From: Robert Klemme Date: 2010-09-27T05:00:13+09:00 Subject: Re: mixing string formatting with system exec On 26.09.2010 21:26, Nate St.Germain wrote: > noob question… > > why does this line produce the following result? > > %x("%s %s" % ['/usr/bin/touch', '/tmp/test']) > > error: > sh: line 0: fg: no job control > > i don't necessarily need to use string formatting or substitution here, > just curious about the result. > > thanks. %x is backticks and the contents between brackets are passed unmodified to the shell: Robert@babelfish ~ $ ruby19 -e 'p %x[ls a]' ls: cannot access a: No such file or directory "" Robert@babelfish ~ $ ruby19 -e 'p %x["ls a"]' sh: ls a: command not found "" You are essentially doing the same as this: irb(main):002:0> system '"%s %s" % [\'/usr/bin/touch\', \'/tmp/test\']' sh: line 0: fg: no job control => false You get the same if you call bash as sh directly: Robert@babelfish ~ $ /bin/sh -c '"%s %s"' /bin/sh: line 0: fg: no job control Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/