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.
On 26.09.2010 21:26, Nate St.Germain wrote:
just curious about the result.
thanks.
%x is backticks and the contents between brackets are passed unmodified
to the shell:
[email protected] ~
$ ruby19 -e ‘p %x[ls a]’
ls: cannot access a: No such file or directory
“”
[email protected] ~
$ 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:
[email protected] ~
$ /bin/sh -c ‘"%s %s"’
/bin/sh: line 0: fg: no job control
Kind regards
robert
Robert K. wrote:
%x is backticks and the contents between brackets are passed unmodified
to the shell:
ahh, got it. thanks, robert.