nushell/crates/nu-command/src
Henry Jetmundsen 253b223e65
pipe binary data to external commands (#8058)
Fixes #7615 

# Description

When calling external commands, we create a table from the pipeline data
to handle external commands expecting paginated input. When a binary
value is made into a table, we convert the vector of bytes representing
the binary bytes into a pretty formatted string. This results in the
pretty formatted string being sent to external commands instead of the
actual binary bytes. By checking whether the stdout of the call is being
redirected, we can decide whether to send the raw binary bytes or the
pretty formatted output when creating a table command.

# User-Facing Changes

When passing binary values to external commands, the external command
will receive the actual bytes instead of the pretty printed string. Use
cases that don't involve piping a binary value into an external command
are unchanged.


![new_behavior](https://user-images.githubusercontent.com/32406734/218349172-24cd12f2-d563-4957-bdf1-6aa804b174b2.png)

# Tests + Formatting

Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

cargo fmt --all -- --check to check standard code formatting (cargo fmt
--all applies these changes)
cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect to check that you're using the standard code
style
    cargo test --workspace to check that all tests pass

# After Submitting

If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
2023-02-24 21:39:52 +01:00
..
bits Use imported names in Command::run signatures (#7967) 2023-02-05 22:17:46 +01:00
bytes Use imported names in Command::run signatures (#7967) 2023-02-05 22:17:46 +01:00
charting Use variable names directly in the format strings (#7906) 2023-01-29 19:37:54 -06:00
conversions Fix one error message in into string (#8163) 2023-02-22 09:05:19 +00:00
database Use variable names directly in the format strings (#7906) 2023-01-29 19:37:54 -06:00
dataframe Cratification: Break out nu_cmd_lang into a separate crate (#8181) 2023-02-24 09:54:42 -06:00
date report which datetime couldn't be converted (#7980) 2023-02-06 14:17:07 -06:00
debug move ast command to the debug group (#8077) 2023-02-14 18:47:34 +00:00
deprecated add benchmark to deprecated commands (#8046) 2023-02-11 21:39:55 +00:00
env TEST: add the output to the new with-env example (#8148) 2023-02-21 10:15:35 +00:00
experimental relocate debug commands (#8071) 2023-02-13 16:39:07 +00:00
filesystem Dependency update: update notify version to v5 (#8114) 2023-02-22 13:35:09 -08:00
filters Cratification: Break out nu_cmd_lang into a separate crate (#8181) 2023-02-24 09:54:42 -06:00
formats show more informaiton when there are toml errors (#8140) 2023-02-20 18:50:31 +00:00
generators Use imported names in Command::run signatures (#7967) 2023-02-05 22:17:46 +01:00
hash move hash md5 and hash sha256 commands to the hash category (#8196) 2023-02-24 11:53:25 -06:00
math Update few examples of math commands (#7987) 2023-02-06 13:43:00 +01:00
misc Use imported names in Command::run signatures (#7967) 2023-02-05 22:17:46 +01:00
network HTTP HEAD / PATCH / PUT / DELETE commands (#8144) 2023-02-23 17:52:12 -06:00
path Use imported names in Command::run signatures (#7967) 2023-02-05 22:17:46 +01:00
platform fix ansi example so it is tested (#8192) 2023-02-24 11:52:51 -06:00
random Use imported names in Command::run signatures (#7967) 2023-02-05 22:17:46 +01:00
shells Add more input/output type annotations (#7532) 2022-12-21 20:20:46 +01:00
strings Improve error when regex rejects pattern. Resolution of #8037 (#8050) 2023-02-12 13:25:40 +00:00
system relocate debug commands (#8071) 2023-02-13 16:39:07 +00:00
viewers pipe binary data to external commands (#8058) 2023-02-24 21:39:52 +01:00
default_context.rs Cratification: Break out nu_cmd_lang into a separate crate (#8181) 2023-02-24 09:54:42 -06:00
example_test.rs Cratification: Break out nu_cmd_lang into a separate crate (#8181) 2023-02-24 09:54:42 -06:00
input_handler.rs Standardise the use of ShellError::UnsupportedInput and ShellError::TypeMismatch and add spans to every instance of the former (#7217) 2022-12-23 01:48:53 -05:00
lib.rs Cratification: Break out nu_cmd_lang into a separate crate (#8181) 2023-02-24 09:54:42 -06:00
progress_bar.rs cp progress bar implementation (#8012) 2023-02-22 11:57:38 -08:00
sort_utils.rs Reduce again the number of match calls (#7815) 2023-01-24 12:23:42 +01:00