Skip to content

Commit cb34c18

Browse files
author
梶塚太智
committed
Update main.rs
upgrade processing of shell command
1 parent dc70704 commit cb34c18

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/main.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -550,12 +550,19 @@ impl Executor {
550550
.hidden(false)
551551
.print_commands(false)
552552
.build();
553-
let result = ps
554-
.run(self.pop_stack().get_string().as_str())
555-
.unwrap()
556-
.stdout()
557-
.unwrap();
558-
self.stack.push(Type::String(result));
553+
let result = ps.run(self.pop_stack().get_string().as_str());
554+
match result {
555+
Ok(i) => self.stack.push(Type::String(
556+
i.stdout()
557+
.unwrap_or("".to_string())
558+
.as_str()
559+
.trim()
560+
.to_string(),
561+
)),
562+
Err(_) => {
563+
self.log_print("エラー! シェルスクリプトの実行に失敗しました".to_string())
564+
}
565+
}
559566
}
560567

561568
// プロセスを終了

0 commit comments

Comments
 (0)