nushell/crates/nu-command/src/filesystem
poketch 16453b6986
Making open case-insensitive to file extensions (#10451)
# Description

Closes #10441 

Uses `String::to_lowercase()` when the file's extension `ext` is parsed
to allow `from_decl(format!("from {ext}"))` to return the desired output
regardless of extension case.

It doesn't work with sqlite files since those are handled earlier in the
parsing but I think is good- since there's no standard file extension
used by sqlite so a user will likely want case sensitivity in that case.

This also has the (possibly undesired) effect of making `open`
completely case insensitive, e.g. `open foo.JSON` will work on a file
named `foo.json` and vice versa. This is good on Windows as it treats
`foo.json` and `foo.JSON` as the same file, but may not be the desired
behaviour on Unix.

If this behaviour is undesired I assume it would be fixed with a
`#[cfg(not(unix))]` attribute on the `to_lowercase()` operation but that
produces slightly "uglier" code that I didn't wish to submit unless
necessary. 

old behaviour:

![image](https://github.com/nushell/nushell/assets/79598494/261df577-e377-44ac-bef3-f6384bceaeb5)

new behaviour: 

![image](https://github.com/nushell/nushell/assets/79598494/04271740-a46f-4613-a3a6-1e220ef7f829)


# User-Facing Changes

`open` will now present a table when `open`-ing files with captitalized
extensions rather than the file's raw data

# Tests + Formatting

new test: `parses_file_with_uppercase_extension` which tests the desired
behaviour

---------

Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
2023-09-29 17:20:59 +02:00
..
cd_query.rs Fix typos by codespell (#7600) 2022-12-26 02:31:26 -05:00
cd.rs show the full directory / file path in "directory not found" error (#10430) 2023-09-26 17:38:58 +08:00
cp.rs show the full directory / file path in "directory not found" error (#10430) 2023-09-26 17:38:58 +08:00
glob.rs glob with ../ prefix now works; (#10504) 2023-09-29 06:48:55 -05:00
ls.rs Move Value to helpers, separate span call (#10121) 2023-09-03 07:27:29 -07:00
mkdir.rs Move Value to helpers, separate span call (#10121) 2023-09-03 07:27:29 -07:00
mod.rs use uutils/coreutils cp command in place of nushell's cp command (#10097) 2023-09-08 13:57:38 -05:00
mv.rs show the full directory / file path in "directory not found" error (#10430) 2023-09-26 17:38:58 +08:00
open.rs Making open case-insensitive to file extensions (#10451) 2023-09-29 17:20:59 +02:00
rm.rs Clean up trash support on Android (#10225) 2023-09-05 14:38:23 +02:00
save.rs Invert &Options to Option<&T> (#10315) 2023-09-13 07:00:58 +08:00
start.rs provide env to commands and try to start provided path (#10302) 2023-09-12 14:03:41 +02:00
touch.rs Document and critically review ShellError variants - Ep. 2 (#8326) 2023-03-06 11:31:07 +01:00
ucp.rs Fix variables not allowed in ucp (#10304) 2023-09-10 17:54:33 -05:00
util.rs Fix cp -u/mv -u when the dst doesn't exist (#9662) 2023-07-12 18:12:59 +02:00
watch.rs show the full directory / file path in "directory not found" error (#10430) 2023-09-26 17:38:58 +08:00