fn determine_command_tuple<'a, T: AsRef<str> + 'a>(shell_command: &'a Option<T>, argv: &'a [T]) -> Result<(&'a str, Vec<&'a str>), Box<dyn Error>> {
	let mut vec: Vec<&str> = vec![];

	// Prepend shell and command string if a command string is given.
	if let Some(shell_command) = shell_command {
		vec.push("/bin/sh");
		vec.push("-c");
		vec.push(shell_command.as_ref());
	}

	// The args given will be the whole command if there's no shell string;
	// otherwise, they'll be added to the argument vector.
	vec.extend(argv.iter().map(|item| item.as_ref()));

	// Shift off the first word as the command, erroring out if no command is
	// given.
	vec.reverse();
	let command = require_with!(vec.pop(), "Empty command!");
	vec.reverse();

	return Ok((command, vec));
}
/// Determines based on the inputs whether we are going to invoke a shell, with
/// shell interpretation, or a simple unescaped argument vector.
/// Rearranges arguments as needed, but doesn't reallocate.
Determines based on the inputs whether we are going to invoke a shell, with
shell interpretation, or a simple unescaped argument vector.
Rearranges arguments as needed, but doesn't reallocate.
Determines based on the inputs whether we are going to invoke a shell with shell interpretation or a simple unescaped argument vector . Rearranges arguments as needed but doesn ' t reallocate .
fn determine_command_tuple<'a, T: AsRef<str> + 'a>(shell_command: &'a Option<T>, argv: &'a [T]) -> Result<(&'a str, Vec<&'a str>), Box<dyn Error>> {
	let mut vec: Vec<&str> = vec![];
	// Prepend shell and command string if a command string is given.
	if let Some(shell_command) = shell_command {
		vec.push("/bin/sh");
		vec.push("-c");
		vec.push(shell_command.as_ref());
	}
	// The args given will be the whole command if there's no shell string;
	// otherwise, they'll be added to the argument vector.
	vec.extend(argv.iter().map(|item| item.as_ref()));
	// Shift off the first word as the command, erroring out if no command is
	// given.
	vec.reverse();
	let command = require_with!(vec.pop(), "Empty command!");
	vec.reverse();
	return Ok((command, vec));
}
fn determine_command_tuple < ' a , T : AsRef < str > + ' a > ( shell_command : & ' a Option < T > , argv : & ' a [ T ] ) -> Result < ( & ' a str , Vec < & ' a str > ) , Box < dyn Error > > { let mut vec : Vec < & str > = vec ! [ ] ; // Prepend shell and command string if a command string is given. if let Some ( shell_command ) = shell_command { vec . push ( " " ) ; vec . push ( " " ) ; vec . push ( shell_command . as_ref ( ) ) ; } // The args given will be the whole command if there's no shell string; // otherwise, they'll be added to the argument vector. vec . extend ( argv . iter ( ) . map ( | item | item . as_ref ( ) ) ) ; // Shift off the first word as the command, erroring out if no command is // given. vec . reverse ( ) ; let command = require_with ! ( vec pop ( ) " " ) ; vec . reverse ( ) ; return Ok ( ( command , vec ) ) ; }
Determines based on the inputs whether we are going to invoke a shell, with
shell interpretation, or a simple unescaped argument vector.
Determines based on the inputs whether we are going to invoke a shell with shell interpretation or a simple unescaped argument vector .
shell_command
&'a Option<T>
argv
&'a [T]