mirror of
https://github.com/nushell/nushell
synced 2025-01-16 07:04:09 +00:00
Fix panic if external is not found
This commit is contained in:
parent
7d4fec4db3
commit
6c0bf6e0ab
1 changed files with 37 additions and 28 deletions
|
@ -317,10 +317,11 @@ impl ExternalCommand {
|
||||||
trace!(target: "nu::run::external", "set up stdin pipe");
|
trace!(target: "nu::run::external", "set up stdin pipe");
|
||||||
trace!(target: "nu::run::external", "built process {:?}", process);
|
trace!(target: "nu::run::external", "built process {:?}", process);
|
||||||
|
|
||||||
let mut popen = process.popen().unwrap();
|
let popen = process.popen();
|
||||||
|
|
||||||
trace!(target: "nu::run::external", "next = {:?}", stream_next);
|
trace!(target: "nu::run::external", "next = {:?}", stream_next);
|
||||||
|
|
||||||
|
if let Ok(mut popen) = popen {
|
||||||
match stream_next {
|
match stream_next {
|
||||||
StreamNext::Last => {
|
StreamNext::Last => {
|
||||||
let _ = popen.detach();
|
let _ = popen.detach();
|
||||||
|
@ -347,11 +348,19 @@ impl ExternalCommand {
|
||||||
let stdout = popen.stdout.take().unwrap();
|
let stdout = popen.stdout.take().unwrap();
|
||||||
let file = futures::io::AllowStdIo::new(stdout);
|
let file = futures::io::AllowStdIo::new(stdout);
|
||||||
let stream = Framed::new(file, LinesCodec {});
|
let stream = Framed::new(file, LinesCodec {});
|
||||||
let stream = stream.map(move |line| Value::string(line.unwrap()).tagged(&name_tag));
|
let stream =
|
||||||
|
stream.map(move |line| Value::string(line.unwrap()).tagged(&name_tag));
|
||||||
Ok(ClassifiedInputStream::from_input_stream(
|
Ok(ClassifiedInputStream::from_input_stream(
|
||||||
stream.boxed() as BoxStream<'static, Tagged<Value>>
|
stream.boxed() as BoxStream<'static, Tagged<Value>>
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return Err(ShellError::labeled_error(
|
||||||
|
"Command not found",
|
||||||
|
"command not found",
|
||||||
|
name_tag,
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue