mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
Always pretty print binary values in table
(#12294)
# Description Binary values passed to `table` may or may not be pretty formatted based on the output destination. This leads to weird behavior as documented in #12287. This PR changes `table` to always pretty print binary values. However, binary values passed to external commands will not be formatted (this is the existing behavior). # User-Facing Changes This is a breaking change. E.g.: ```nushell 0x[8989] | table | cat - ``` used to print raw bytes, but it will now print the pretty formatted bytes. # After Submitting Add to 0.92.0 release notes and update documentation.
This commit is contained in:
@ -466,20 +466,26 @@ impl ExternalCommand {
|
||||
thread::Builder::new()
|
||||
.name("external stdin worker".to_string())
|
||||
.spawn(move || {
|
||||
let stack = &mut stack.start_capture();
|
||||
// Attempt to render the input as a table before piping it to the external.
|
||||
// This is important for pagers like `less`;
|
||||
// they need to get Nu data rendered for display to users.
|
||||
//
|
||||
// TODO: should we do something different for list<string> inputs?
|
||||
// Users often expect those to be piped to *nix tools as raw strings separated by newlines
|
||||
let input = crate::Table::run(
|
||||
&crate::Table,
|
||||
&engine_state,
|
||||
stack,
|
||||
&Call::new(head),
|
||||
input,
|
||||
);
|
||||
let input = match input {
|
||||
input @ PipelineData::Value(Value::Binary { .. }, ..) => {
|
||||
Ok(input)
|
||||
}
|
||||
input => {
|
||||
let stack = &mut stack.start_capture();
|
||||
// Attempt to render the input as a table before piping it to the external.
|
||||
// This is important for pagers like `less`;
|
||||
// they need to get Nu data rendered for display to users.
|
||||
//
|
||||
// TODO: should we do something different for list<string> inputs?
|
||||
// Users often expect those to be piped to *nix tools as raw strings separated by newlines
|
||||
crate::Table.run(
|
||||
&engine_state,
|
||||
stack,
|
||||
&Call::new(head),
|
||||
input,
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
if let Ok(input) = input {
|
||||
for value in input.into_iter() {
|
||||
|
Reference in New Issue
Block a user