run-external is expanding globs (but shouldn't on Windows) with no way to opt out
Describe the bug
I am attempting to use regex-cli, which is an external exe which takes a regex as a CLI parameter. This regex has glob special characters in it and cannot escape the glob characters, and I want to load the large regex from a variable. The argument completely disappears, because Nushell expands it as a glob and doesn't find any files matching the regex-interpreted-as-glob. I am left wondering why my command which was working before (a regex that happened not to get mangled) now is trying to open a file called ⚽.
How to reproduce
D:/.config/nushell> ls *.nu
╭───┬───────────────────┬──────┬──────────┬─────────────╮
│ # │ name │ type │ size │ modified │
├───┼───────────────────┼──────┼──────────┼─────────────┤
│ 0 │ config.nu │ file │ 443 B │ 2 weeks ago │
│ 1 │ default-config.nu │ file │ 23.9 KiB │ 2 days ago │
│ 2 │ env.nu │ file │ 1.1 KiB │ 2 weeks ago │
│ 3 │ prompt.nu │ file │ 2.4 KiB │ 2 days ago │
╰───┴───────────────────┴──────┴──────────┴─────────────╯
D:/.config/nushell> ^echo *.nu
config.nu default-config.nu env.nu prompt.nu
D:/.config/nushell> let x = '*.nu'
D:/.config/nushell> ^echo $'($x)' # attempt (fail) to suppress globbing
config.nu default-config.nu env.nu prompt.nu
Expected behavior
I expected ^command and run-external command to not perform glob expansion (on Windows), because that's how the CLI has always worked on windows -- if glob expansion is wanted, the program or the pipeline implements it.
Screenshots
No response
Configuration
| key | value |
|---|---|
| version | 0.90.1 |
| branch | |
| commit_hash | c2992d5d8b8541b64e9fc1440ed2917fc9b757f7 |
| build_os | windows-x86_64 |
| build_target | x86_64-pc-windows-msvc |
| rust_version | rustc 1.73.0 (cc66ad468 2023-10-03) |
| rust_channel | 1.73.0-x86_64-pc-windows-msvc |
| cargo_version | cargo 1.73.0 (9c4383fb5 2023-08-26) |
| build_time | 2024-02-07 02:25:09 +00:00 |
| build_rust_channel | release |
| allocator | mimalloc |
| features | default, sqlite, trash, which, zip |
| installed_plugins |
Additional context
I can absolutely buy nushell-native commands doing globbing with whatever semantics nushell decides is the most reasonable. But changing the semantics of running extern commands is really bad for a shell to be doing. I like nushell but this is actually a blocker on using it as a daily shell 🙃
Can you see how far you get with the latest main? @WindSoilder has been making some globbing changes. There's also this PR which isn't landed yet which may come into play https://github.com/nushell/nushell/pull/11886?