mirror of
https://github.com/nushell/nushell.git
synced 2025-01-11 16:58:41 +01:00
fix semicolon doesn't work for some commands (#7373)
# Description Fix semicolon working for the following commands which runs to failed: 1. into record (example: `into record; echo 'aa'`) -- the final aa shouldn't be printed 2. save ( example: `touch a; chmod a-w a; echo 'aa' | save a; echo asdf` ) -- the final asdf shouldn't be printed 3. fetch ( example: `touch a; chmod a-w a; fetch https://www.google.com -o a; echo asdf` ) -- the final asdf shouldn't be printed 4. registry_query (I don't have window machine, sorry for that I can't demo for it) I've reviewed most of built-in commands, and it seems that other commands works fine. # User-Facing Changes # 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.
This commit is contained in:
parent
5114dfca7d
commit
d18587330a
@ -183,12 +183,12 @@ fn into_record(
|
|||||||
Value::Record { cols, vals, span }
|
Value::Record { cols, vals, span }
|
||||||
}
|
}
|
||||||
Value::Record { cols, vals, span } => Value::Record { cols, vals, span },
|
Value::Record { cols, vals, span } => Value::Record { cols, vals, span },
|
||||||
other => Value::Error {
|
other => {
|
||||||
error: ShellError::UnsupportedInput(
|
return Err(ShellError::UnsupportedInput(
|
||||||
"'into record' does not support this input".into(),
|
"'into record' does not support this input".into(),
|
||||||
other.span().unwrap_or(call.head),
|
other.span().unwrap_or(call.head),
|
||||||
),
|
))
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
Ok(res.into_pipeline_data())
|
Ok(res.into_pipeline_data())
|
||||||
}
|
}
|
||||||
|
@ -91,17 +91,12 @@ impl Command for Save {
|
|||||||
let mut file = match file {
|
let mut file = match file {
|
||||||
Ok(file) => file,
|
Ok(file) => file,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
return Ok(PipelineData::Value(
|
return Err(ShellError::GenericError(
|
||||||
Value::Error {
|
|
||||||
error: ShellError::GenericError(
|
|
||||||
"Permission denied".into(),
|
"Permission denied".into(),
|
||||||
err.to_string(),
|
err.to_string(),
|
||||||
Some(arg_span),
|
Some(arg_span),
|
||||||
None,
|
None,
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
),
|
|
||||||
},
|
|
||||||
None,
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -117,17 +112,12 @@ impl Command for Save {
|
|||||||
match std::fs::File::create(stderr_path) {
|
match std::fs::File::create(stderr_path) {
|
||||||
Ok(file) => Some(file),
|
Ok(file) => Some(file),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
return Ok(PipelineData::Value(
|
return Err(ShellError::GenericError(
|
||||||
Value::Error {
|
|
||||||
error: ShellError::GenericError(
|
|
||||||
"Permission denied".into(),
|
"Permission denied".into(),
|
||||||
err.to_string(),
|
err.to_string(),
|
||||||
Some(stderr_span),
|
Some(stderr_span),
|
||||||
None,
|
None,
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
),
|
|
||||||
},
|
|
||||||
None,
|
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,17 +135,12 @@ impl Command for SubCommand {
|
|||||||
Err(err) => {
|
Err(err) => {
|
||||||
let arg_span =
|
let arg_span =
|
||||||
call.get_named_arg("output").expect("arg should exist").span;
|
call.get_named_arg("output").expect("arg should exist").span;
|
||||||
return Ok(PipelineData::Value(
|
return Err(ShellError::GenericError(
|
||||||
Value::Error {
|
|
||||||
error: ShellError::GenericError(
|
|
||||||
"Permission denied".into(),
|
"Permission denied".into(),
|
||||||
err.to_string(),
|
err.to_string(),
|
||||||
Some(arg_span),
|
Some(arg_span),
|
||||||
None,
|
None,
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
),
|
|
||||||
},
|
|
||||||
None,
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -146,16 +146,13 @@ fn registry_query(
|
|||||||
}
|
}
|
||||||
.into_pipeline_data())
|
.into_pipeline_data())
|
||||||
}
|
}
|
||||||
Err(_) => Ok(Value::Error {
|
Err(_) => Err(ShellError::GenericError(
|
||||||
error: ShellError::GenericError(
|
|
||||||
"Unable to find registry key/value".to_string(),
|
"Unable to find registry key/value".to_string(),
|
||||||
format!("Registry value: {} was not found", value.item),
|
format!("Registry value: {} was not found", value.item),
|
||||||
Some(value.span),
|
Some(value.span),
|
||||||
None,
|
None,
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
),
|
)),
|
||||||
}
|
|
||||||
.into_pipeline_data()),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => Ok(Value::nothing(Span::test_data()).into_pipeline_data()),
|
None => Ok(Value::nothing(Span::test_data()).into_pipeline_data()),
|
||||||
|
Loading…
Reference in New Issue
Block a user