mirror of
https://github.com/nushell/nushell
synced 2024-12-28 05:53:09 +00:00
fix var names coming from long/short flags (#6142)
This commit is contained in:
parent
9695331eed
commit
c8adb06ca7
1 changed files with 8 additions and 1 deletions
|
@ -3226,7 +3226,14 @@ pub fn parse_signature_helper(
|
||||||
String::from_utf8_lossy(short_flag).to_string();
|
String::from_utf8_lossy(short_flag).to_string();
|
||||||
let chars: Vec<char> = short_flag.chars().collect();
|
let chars: Vec<char> = short_flag.chars().collect();
|
||||||
let long = String::from_utf8_lossy(&flags[0][2..]).to_string();
|
let long = String::from_utf8_lossy(&flags[0][2..]).to_string();
|
||||||
let variable_name = flags[0][2..].to_vec();
|
let mut variable_name = flags[0][2..].to_vec();
|
||||||
|
|
||||||
|
(0..variable_name.len()).for_each(|idx| {
|
||||||
|
if variable_name[idx] == b'-' {
|
||||||
|
variable_name[idx] = b'_';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if !is_variable(&variable_name) {
|
if !is_variable(&variable_name) {
|
||||||
error = error.or_else(|| {
|
error = error.or_else(|| {
|
||||||
Some(ParseError::Expected(
|
Some(ParseError::Expected(
|
||||||
|
|
Loading…
Reference in a new issue