소스 검색

Only one Pipe accepted now.

Lorenz Bung 7 년 전
부모
커밋
5af91274eb
1개의 변경된 파일8개의 추가작업 그리고 0개의 파일을 삭제
  1. 8
    0
      hw7/task2/src/lib.rs

+ 8
- 0
hw7/task2/src/lib.rs 파일 보기

@@ -135,6 +135,14 @@ impl<R: BufRead, W: Write> Shell<R, W> {
135 135
                 let commands = cmd.split('|');
136 136
                 let commands_vec: Vec<&str> = commands.collect();
137 137
 
138
+                if commands_vec.len() > 2 {
139
+                    let _ = self.writer.write_all(
140
+                        format!("Error: Only one pipe supported at the moment.\n")
141
+                            .as_bytes(),
142
+                    );
143
+                    return Err(ErrorType::BrokenPipeError);
144
+                }
145
+
138 146
                 let needs_pipe = commands_vec.len() == 2;
139 147
 
140 148
 

Loading…
취소
저장