Fix bug with multiple input objects to an external command.

Previously, we would build a command that looked something like this:

  <ex_cmd> "$it" "&&" "<ex_cmd>" "$it"

So that the "&&" and "<ex_cmd>" would also be arguments to the command,
instead of a chained command. This commit builds up a command string
that can be passed to an external shell.
This commit is contained in:
Jason Gedge
2019-10-14 16:30:23 -04:00
parent d38b8cf851
commit ee8cd671cb
3 changed files with 110 additions and 40 deletions

View File

@ -164,6 +164,28 @@ fn save_figures_out_intelligently_where_to_write_out_with_metadata() {
})
}
#[test]
fn it_arg_works_with_many_inputs_to_external_command() {
Playground::setup("it_arg_works_with_many_inputs", |dirs, sandbox| {
sandbox.with_files(vec![
FileWithContent("file1", "text"),
FileWithContent("file2", " and more text"),
]);
let (stdout, stderr) = nu_combined!(
cwd: dirs.test(), h::pipeline(
r#"
echo file1 file2
| split-row " "
| cat $it
"#
));
assert_eq!("text and more text", stdout);
assert!(!stderr.contains("No such file or directory"));
})
}
#[test]
fn save_can_write_out_csv() {
Playground::setup("save_test_2", |dirs, _| {