From: Ross Bamford Date: 2005-12-18T22:38:10+09:00 Subject: Re: Spawning On Sun, 18 Dec 2005 12:58:09 -0000, Stefan Lang wrote: > On Sunday 18 December 2005 13:43, Steve Litt wrote: >> On Sunday 18 December 2005 04:46 am, Florian Frank wrote: >> > Steve Litt wrote: >> > >I converted the array of arguments to a string, and it worked. >> > > But it should have worked the other way too. What am I missing? >> > >> > exec *argarray >> >> Confirmed! Thanks Florian. >> >> Now I can run a command with several words quoted together to make >> one argument. >> >> Curious -- what does the asterisk do to make it work when it didn't >> work without the asterisk. What does the asterisk do? I know it >> doesn't mean "the contents of this address" -- that's another >> language :-) > > It flattens the array (argarray) into an argument list. > This means the first element of argarray becomes the first > argument to exec, the second element of argarray becomes > the second argument to exec and so on. > I've seen it also called the 'splat' operator, and (I think?) David Black called it the 'unary unarray' operator, which I a good name for it. It doesn't just work with method arguments, and it doesn't just work with arrays: p = *File.open('/etc/passwd') gives an array of all the lines in the file. I was most impressed when I found that out recently ;) (p.s. I'm not advocating that method of reading files _at all_ - it's just an example) -- Ross Bamford - rosco@roscopeco.remove.co.uk