A random set of fixes (#1600)

This commit is contained in:
Jonathan Turner 2020-04-17 18:19:49 +12:00 committed by GitHub
parent ee778d2b03
commit 52d2d2b888
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 8 deletions

View File

@ -398,8 +398,13 @@ pub async fn run_vec_of_pipelines(
} => {
for pipeline in pipelines {
if let Ok(pipeline_string) = pipeline.as_string() {
let _ =
run_pipeline_standalone(pipeline_string, false, &mut context).await;
let _ = run_pipeline_standalone(
pipeline_string,
false,
&mut context,
false,
)
.await;
}
}
}
@ -411,7 +416,7 @@ pub async fn run_vec_of_pipelines(
}
for pipeline in pipelines {
run_pipeline_standalone(pipeline, redirect_stdin, &mut context).await?;
run_pipeline_standalone(pipeline, redirect_stdin, &mut context, true).await?;
}
Ok(())
}
@ -420,6 +425,7 @@ pub async fn run_pipeline_standalone(
pipeline: String,
redirect_stdin: bool,
context: &mut Context,
exit_on_error: bool,
) -> Result<(), Box<dyn Error>> {
let line = process_line(Ok(pipeline), context, redirect_stdin, false).await;
@ -448,7 +454,9 @@ pub async fn run_pipeline_standalone(
});
context.maybe_print_errors(Text::from(line));
std::process::exit(1);
if exit_on_error {
std::process::exit(1);
}
}
_ => {}
@ -502,8 +510,13 @@ pub async fn cli() -> Result<(), Box<dyn Error>> {
} => {
for pipeline in pipelines {
if let Ok(pipeline_string) = pipeline.as_string() {
let _ =
run_pipeline_standalone(pipeline_string, false, &mut context).await;
let _ = run_pipeline_standalone(
pipeline_string,
false,
&mut context,
false,
)
.await;
}
}
}

View File

@ -444,6 +444,8 @@ fn spawn(
process.arg("/c");
process.arg(&command.name);
for arg in args {
// Clean the args before we use them:
let arg = arg.replace("|", "\\|");
process.arg(&arg);
}
process

View File

@ -76,6 +76,12 @@ impl PerItemCommand for Help {
return Ok(
get_help(&command.name(), &command.usage(), command.signature()).into(),
);
} else {
return Err(ShellError::labeled_error(
"Can't find command (use 'help commands' for full list)",
"can't find command",
tag,
));
}
let help = futures::stream::iter(help);
Ok(help.to_output_stream())

View File

@ -69,15 +69,15 @@ impl NuCompleter {
for command in commands.iter() {
let mut pos = replace_pos;
let mut matched = true;
let mut matched = false;
if pos < line_chars.len() {
for chr in command.chars() {
if line_chars[pos] != chr {
matched = false;
break;
}
pos += 1;
if pos == line_chars.len() {
matched = true;
break;
}
}