forked from extern/nushell
A random set of fixes (#1600)
This commit is contained in:
parent
ee778d2b03
commit
52d2d2b888
@ -398,8 +398,13 @@ pub async fn run_vec_of_pipelines(
|
|||||||
} => {
|
} => {
|
||||||
for pipeline in pipelines {
|
for pipeline in pipelines {
|
||||||
if let Ok(pipeline_string) = pipeline.as_string() {
|
if let Ok(pipeline_string) = pipeline.as_string() {
|
||||||
let _ =
|
let _ = run_pipeline_standalone(
|
||||||
run_pipeline_standalone(pipeline_string, false, &mut context).await;
|
pipeline_string,
|
||||||
|
false,
|
||||||
|
&mut context,
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -411,7 +416,7 @@ pub async fn run_vec_of_pipelines(
|
|||||||
}
|
}
|
||||||
|
|
||||||
for pipeline in 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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -420,6 +425,7 @@ pub async fn run_pipeline_standalone(
|
|||||||
pipeline: String,
|
pipeline: String,
|
||||||
redirect_stdin: bool,
|
redirect_stdin: bool,
|
||||||
context: &mut Context,
|
context: &mut Context,
|
||||||
|
exit_on_error: bool,
|
||||||
) -> Result<(), Box<dyn Error>> {
|
) -> Result<(), Box<dyn Error>> {
|
||||||
let line = process_line(Ok(pipeline), context, redirect_stdin, false).await;
|
let line = process_line(Ok(pipeline), context, redirect_stdin, false).await;
|
||||||
|
|
||||||
@ -448,8 +454,10 @@ pub async fn run_pipeline_standalone(
|
|||||||
});
|
});
|
||||||
|
|
||||||
context.maybe_print_errors(Text::from(line));
|
context.maybe_print_errors(Text::from(line));
|
||||||
|
if exit_on_error {
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
@ -502,8 +510,13 @@ pub async fn cli() -> Result<(), Box<dyn Error>> {
|
|||||||
} => {
|
} => {
|
||||||
for pipeline in pipelines {
|
for pipeline in pipelines {
|
||||||
if let Ok(pipeline_string) = pipeline.as_string() {
|
if let Ok(pipeline_string) = pipeline.as_string() {
|
||||||
let _ =
|
let _ = run_pipeline_standalone(
|
||||||
run_pipeline_standalone(pipeline_string, false, &mut context).await;
|
pipeline_string,
|
||||||
|
false,
|
||||||
|
&mut context,
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -444,6 +444,8 @@ fn spawn(
|
|||||||
process.arg("/c");
|
process.arg("/c");
|
||||||
process.arg(&command.name);
|
process.arg(&command.name);
|
||||||
for arg in args {
|
for arg in args {
|
||||||
|
// Clean the args before we use them:
|
||||||
|
let arg = arg.replace("|", "\\|");
|
||||||
process.arg(&arg);
|
process.arg(&arg);
|
||||||
}
|
}
|
||||||
process
|
process
|
||||||
|
@ -76,6 +76,12 @@ impl PerItemCommand for Help {
|
|||||||
return Ok(
|
return Ok(
|
||||||
get_help(&command.name(), &command.usage(), command.signature()).into(),
|
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);
|
let help = futures::stream::iter(help);
|
||||||
Ok(help.to_output_stream())
|
Ok(help.to_output_stream())
|
||||||
|
@ -69,15 +69,15 @@ impl NuCompleter {
|
|||||||
|
|
||||||
for command in commands.iter() {
|
for command in commands.iter() {
|
||||||
let mut pos = replace_pos;
|
let mut pos = replace_pos;
|
||||||
let mut matched = true;
|
let mut matched = false;
|
||||||
if pos < line_chars.len() {
|
if pos < line_chars.len() {
|
||||||
for chr in command.chars() {
|
for chr in command.chars() {
|
||||||
if line_chars[pos] != chr {
|
if line_chars[pos] != chr {
|
||||||
matched = false;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pos += 1;
|
pos += 1;
|
||||||
if pos == line_chars.len() {
|
if pos == line_chars.len() {
|
||||||
|
matched = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user