diff --git a/crates/nu-command/src/filters/get.rs b/crates/nu-command/src/filters/get.rs index 44148302e7..78d01b1e74 100644 --- a/crates/nu-command/src/filters/get.rs +++ b/crates/nu-command/src/filters/get.rs @@ -46,9 +46,9 @@ If multiple cell paths are given, this will produce a list of values."# Some('i'), ) .switch( - "sensitive", - "get path in a case sensitive manner", - Some('s'), + "ignore-case", + "get path in a case insensitive manner (make all cell path members case insensitive)", + Some('I'), ) .allow_variants_without_examples(true) .category(Category::Filters) @@ -87,12 +87,12 @@ If multiple cell paths are given, this will produce a list of values."# }, Example { description: "Getting Path/PATH in a case insensitive way", - example: "$env | get paTH", + example: "$env | get --ignore-case paTH", result: None, }, Example { description: "Getting Path in a case sensitive way, won't work for 'PATH'", - example: "$env | get --sensitive Path", + example: "$env | get Path", result: None, }, ] @@ -111,14 +111,14 @@ If multiple cell paths are given, this will produce a list of values."# let cell_path: CellPath = call.req_const(working_set, 0)?; let rest: Vec = call.rest_const(working_set, 1)?; let ignore_errors = call.has_flag_const(working_set, "ignore-errors")?; - let sensitive = call.has_flag_const(working_set, "sensitive")?; + let ignore_case = call.has_flag_const(working_set, "ignore-case")?; let metadata = input.metadata(); action( input, cell_path, rest, ignore_errors, - sensitive, + ignore_case, working_set.permanent().signals().clone(), call.head, ) @@ -135,14 +135,14 @@ If multiple cell paths are given, this will produce a list of values."# let cell_path: CellPath = call.req(engine_state, stack, 0)?; let rest: Vec = call.rest(engine_state, stack, 1)?; let ignore_errors = call.has_flag(engine_state, stack, "ignore-errors")?; - let sensitive = call.has_flag(engine_state, stack, "sensitive")?; + let ignore_case = call.has_flag(engine_state, stack, "ignore-case")?; let metadata = input.metadata(); action( input, cell_path, rest, ignore_errors, - sensitive, + ignore_case, engine_state.signals().clone(), call.head, ) @@ -155,7 +155,7 @@ fn action( mut cell_path: CellPath, mut rest: Vec, ignore_errors: bool, - sensitive: bool, + ignore_case: bool, signals: Signals, span: Span, ) -> Result { @@ -166,6 +166,13 @@ fn action( } } + if ignore_case { + cell_path.make_insensitive(); + for path in &mut rest { + path.make_insensitive(); + } + } + match input { PipelineData::Empty => return Err(ShellError::PipelineEmpty { dst_span: span }), // Allow chaining of get -i