pub fn core_command(&mut self, cmd: &str, chunk: &Chunk, i: usize) -> i32 {
        let prepared_cmd_opt = self.prepare_and_split_command(cmd, chunk, i);
        if prepared_cmd_opt.is_none() {
            return 0;
        }
        let (executable, args) = prepared_cmd_opt.unwrap();

        let process_res =
            Command::new(executable).args(args).stdout(Stdio::piped()).spawn();
        match process_res {
            Ok(process) => {
                let upstream_stdout = process.stdout.unwrap();
                let cmd_generator =
                    Value::CommandGenerator(BufReader::new(upstream_stdout));
                self.stack.push(Rc::new(RefCell::new(cmd_generator)));
            }
            Err(e) => {
                let err_str = format!("unable to run command: {}", e.to_string());
                print_error(chunk, i, &err_str);
                return 0;
            }
        }
        return 1;
    }
/// Takes a command string as its single argument.  Substitutes
/// for placeholders, executes the command, and places a generator
/// over the standard output of the command onto the stack.
Takes a command string as its single argument.  Substitutes
for placeholders, executes the command, and places a generator
over the standard output of the command onto the stack.
Takes a command string as its single argument . Substitutes for placeholders executes the command and places a generator over the standard output of the command onto the stack .
pub fn core_command(&mut self, cmd: &str, chunk: &Chunk, i: usize) -> i32 {
        let prepared_cmd_opt = self.prepare_and_split_command(cmd, chunk, i);
        if prepared_cmd_opt.is_none() {
            return 0;
        }
        let (executable, args) = prepared_cmd_opt.unwrap();
        let process_res =
            Command::new(executable).args(args).stdout(Stdio::piped()).spawn();
        match process_res {
            Ok(process) => {
                let upstream_stdout = process.stdout.unwrap();
                let cmd_generator =
                    Value::CommandGenerator(BufReader::new(upstream_stdout));
                self.stack.push(Rc::new(RefCell::new(cmd_generator)));
            }
            Err(e) => {
                let err_str = format!("unable to run command: {}", e.to_string());
                print_error(chunk, i, &err_str);
                return 0;
            }
        }
        return 1;
    }
pub fn core_command ( & mut self , cmd : & str , chunk : & Chunk , i : usize ) -> i32 { let prepared_cmd_opt = self . prepare_and_split_command ( cmd , chunk , i ) ; if prepared_cmd_opt . is_none ( ) { return 0 ; } let ( executable , args ) = prepared_cmd_opt . unwrap ( ) ; let process_res = Command :: new ( executable ) . args ( args ) . stdout ( Stdio :: piped ( ) ) . spawn ( ) ; match process_res { Ok ( process ) => { let upstream_stdout = process . stdout . unwrap ( ) ; let cmd_generator = Value :: CommandGenerator ( BufReader :: new ( upstream_stdout ) ) ; self . stack . push ( Rc :: new ( RefCell :: new ( cmd_generator ) ) ) ; } Err ( e ) => { let err_str = format ! ( " " e to_string ( ) ) ; print_error ( chunk , i , & err_str ) ; return 0 ; } } return 1 ; }
Takes a command string as its single argument.
Takes a command string as its single argument .
&mut self
cmd
&str
chunk
&Chunk
i
usize