def tokenize(val)
val.replace(interpolate_string(val)) if command_options[:interpolate]
self.class.command_regex =~ val
raise CommandError, "fatal: called a command which didn't match?!" unless Regexp.last_match
captures = Regexp.last_match.captures
pos = Regexp.last_match.end(0)
arg_string = val[pos..-1]
arg_string.slice!(0) if arg_string.start_with?(" ")
if arg_string
args = command_options[:shellwords] ? Shellwords.shellwords(arg_string) : arg_string.split(" ")
else
args = []
end
[val[0..pos].rstrip, arg_string, captures, args]
end