ソースを参照

修复exec执行不存在的命令或文件时panic的问题 (#7)

修复exec执行不存在的命令或路径时panic的问题
MemoryShore 1 年間 前
コミット
ca68cd1723
1 ファイル変更3 行追加2 行削除
  1. 3 2
      src/shell/command/mod.rs

+ 3 - 2
src/shell/command/mod.rs

@@ -442,8 +442,9 @@ impl Shell {
             let mut dir_collection = Env::path();
             dir_collection.insert(0, self.current_dir());
             for dir in dir_collection {
-                real_path = format!("{}/{}", dir, path);
-                if Path::new(&real_path).is_file() {
+                let possible_path = format!("{}/{}", dir, path);
+                if Path::new(&path).is_file() {
+                    real_path = possible_path;
                     break;
                 }
             }