浏览代码

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
 

正在加载...
取消
保存