mirror of
https://github.com/nushell/nushell.git
synced 2024-11-23 00:43:33 +01:00
Fix panic if external is not found
This commit is contained in:
parent
7d4fec4db3
commit
6c0bf6e0ab
@ -317,41 +317,50 @@ 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);
|
||||||
|
|
||||||
match stream_next {
|
if let Ok(mut popen) = popen {
|
||||||
StreamNext::Last => {
|
match stream_next {
|
||||||
let _ = popen.detach();
|
StreamNext::Last => {
|
||||||
loop {
|
let _ = popen.detach();
|
||||||
match popen.poll() {
|
loop {
|
||||||
None => {
|
match popen.poll() {
|
||||||
let _ = std::thread::sleep(std::time::Duration::new(0, 100000000));
|
None => {
|
||||||
}
|
let _ = std::thread::sleep(std::time::Duration::new(0, 100000000));
|
||||||
_ => {
|
}
|
||||||
let _ = popen.terminate();
|
_ => {
|
||||||
break;
|
let _ = popen.terminate();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Ok(ClassifiedInputStream::new())
|
||||||
|
}
|
||||||
|
StreamNext::External => {
|
||||||
|
let _ = popen.detach();
|
||||||
|
let stdout = popen.stdout.take().unwrap();
|
||||||
|
Ok(ClassifiedInputStream::from_stdout(stdout))
|
||||||
|
}
|
||||||
|
StreamNext::Internal => {
|
||||||
|
let _ = popen.detach();
|
||||||
|
let stdout = popen.stdout.take().unwrap();
|
||||||
|
let file = futures::io::AllowStdIo::new(stdout);
|
||||||
|
let stream = Framed::new(file, LinesCodec {});
|
||||||
|
let stream =
|
||||||
|
stream.map(move |line| Value::string(line.unwrap()).tagged(&name_tag));
|
||||||
|
Ok(ClassifiedInputStream::from_input_stream(
|
||||||
|
stream.boxed() as BoxStream<'static, Tagged<Value>>
|
||||||
|
))
|
||||||
}
|
}
|
||||||
Ok(ClassifiedInputStream::new())
|
|
||||||
}
|
|
||||||
StreamNext::External => {
|
|
||||||
let _ = popen.detach();
|
|
||||||
let stdout = popen.stdout.take().unwrap();
|
|
||||||
Ok(ClassifiedInputStream::from_stdout(stdout))
|
|
||||||
}
|
|
||||||
StreamNext::Internal => {
|
|
||||||
let _ = popen.detach();
|
|
||||||
let stdout = popen.stdout.take().unwrap();
|
|
||||||
let file = futures::io::AllowStdIo::new(stdout);
|
|
||||||
let stream = Framed::new(file, LinesCodec {});
|
|
||||||
let stream = stream.map(move |line| Value::string(line.unwrap()).tagged(&name_tag));
|
|
||||||
Ok(ClassifiedInputStream::from_input_stream(
|
|
||||||
stream.boxed() as BoxStream<'static, Tagged<Value>>
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return Err(ShellError::labeled_error(
|
||||||
|
"Command not found",
|
||||||
|
"command not found",
|
||||||
|
name_tag,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user