Adds error printing back in a couple places (#5400)

This commit is contained in:
JT 2022-05-02 08:40:46 +12:00 committed by GitHub
parent 92785ab92c
commit 14c9bd44ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,8 +5,8 @@ use std::{
use crate::{
ast::{Call, PathMember},
engine::{EngineState, Stack},
Config, ListStream, RawStream, ShellError, Span, Value,
engine::{EngineState, Stack, StateWorkingSet},
format_error, Config, ListStream, RawStream, ShellError, Span, Value,
};
/// The foundational abstraction for input and output to commands
@ -455,7 +455,15 @@ impl PipelineData {
for item in table {
let stdout = std::io::stdout();
let mut out = item.into_string("\n", config);
let mut out = if let Value::Error { error } = item {
let working_set = StateWorkingSet::new(engine_state);
format_error(&working_set, &error)
} else {
item.into_string("\n", config)
};
out.push('\n');
match stdout.lock().write_all(out.as_bytes()) {
@ -467,7 +475,13 @@ impl PipelineData {
None => {
for item in self {
let stdout = std::io::stdout();
let mut out = item.into_string("\n", config);
let mut out = if let Value::Error { error } = item {
let working_set = StateWorkingSet::new(engine_state);
format_error(&working_set, &error)
} else {
item.into_string("\n", config)
};
out.push('\n');
match stdout.lock().write_all(out.as_bytes()) {