As is known, the Ruby’s Kernel#spawn method executes the specified command and returns its pid. The method can accept either a whole command line as a single argument, a command name and any number of the command’s arguments or an array where the first element is the command itself and the second is, according to the documentation, the strange variable argv[0]. As it turned out, the variable has nothing to do with the Ruby’s ARGV[0].
What is this variable? What does it contain?
Thanks.
Debian GNU/Linux 6.0.2;
Ruby 1.9.3-p0.
I don’t think it’s a variable at all.
When executing a command (in the general case), the arguments go into
argv[1]toargv[*n*]. The name of the command executed can be found inargv[0]. (For Ruby applications, they will be placed inARGV, for C applications they can be accessed using theargcandargvarguments tomain.)By default,
argv[0]will be the same as the command started. However, if you use following form:The program
alphawill be executed, but it’sargv[0]will bebeta.