Reputation: 3057
I have a function that accepts n
number of parameters (it's the devinus/sh function) where you can execute a command line program and obtain the results:
Example: Sh.file "-b", "--mime-type", path_to_file
But I want to have the parameters in an array so they can be varying depending on how the function is called.
Example of what I want:
data = ["-b", "--mime-type", path_to_file]
# a way of going through the array and turning it into the parameters for the Sh function
Sh.file <loop array params here>
Sh doesn't take an array for a parameter.
Any ideas?
Upvotes: 8
Views: 756
Reputation: 9261
You can use apply(Sh, :file, args)
, where args
is an array of arguments.
Upvotes: 9