Reputation: 4329
I was reading the doc of Ruby's system
method here. If I put in the option -P /public/google
(specifying the directory for downloading), does that count as one argument or two arguments, or either?
Upvotes: 0
Views: 322
Reputation: 20408
It actually depends which form of system you use. If you pass a command string, ala:
system 'somecmd -P /public/google'
The command string will be interpreted through the shell which will parse it, tokenizing on whitespace resulting in two arguments to somecmd. Likewise if you use the argument list form and you break the string up into whitespace delimited tokens, like:
system 'somecmd', '-P', '/public/google'
system *%w{ somecmd -P /public/google }
But if you use the argument list form, and send -P /public/google
as a single argument it will appear to somecmd as a one argument with embedded whitespace:
system 'somecmd', '-P /public/google'
Upvotes: 3
Reputation: 2505
It counts as two. Since there's a space in between the two, the shell sees it and splits it as -P
and /public/google
(if you've worked with arguments, even in ruby, the shell would pass those in as separate arguments to the script).
Upvotes: 1