From: Dan Q Date: 2009-11-11T17:45:28+09:00 Subject: Re: Calling a subprocess with specific arguments and capturing its output? On Tue, Nov 10, 2009 at 9:48 PM, Tony Arcieri wrote: > On Tue, Nov 10, 2009 at 4:00 PM, Dan Q wrote: > >> I was looking for a function with a syntax that allows >> separate arguments, like system("du", "-sh", filename) >> > > Why is this any harder than? > > `#{cmd} #{args.map { |arg| arg.to_s.inspect }.join(' ')}` That comes a lot closer to working than I had expected ;) I'd rather not deal with escaping, at all. Won't shell commands in backticks be run differently, depending on what the system shell is? I'm not sure whether all unix shells have similar escaping syntax. The escaping done by inspect() seems to fail when the filename begins with whitespace or contains a newline. -Dan