-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Labels
A:coreutils-uutilsChanges relating to coreutils/uutilsChanges relating to coreutils/uutilsA:file-systemRelated to commands and core nushell behavior around the file systemRelated to commands and core nushell behavior around the file systemA:globBehavior around file-system globbing with regular commands or `glob`. See also A:quoting/expansionBehavior around file-system globbing with regular commands or `glob`. See also A:quoting/expansion
Milestone
Description
Describe the bug
Related: #9310
rm directly passes current_directory to nu_glob without escaping, so the path itself is also expanded as globs.
For example, run rm a under /tmp/* will also delete /tmp/b/a, /tmp/whatever/a:
❯ ls **/*
╭────┬──────────┬──────┬───────┬────────────────╮
│ # │ name │ type │ size │ modified │
├────┼──────────┼──────┼───────┼────────────────┤
│ 0 │ * │ dir │ 192 B │ a minute ago │
│ 1 │ */a │ file │ 0 B │ a minute ago │
│ 2 │ */b │ file │ 0 B │ a minute ago │
│ 3 │ */c │ file │ 0 B │ a minute ago │
│ 4 │ */d │ file │ 0 B │ a minute ago │
│ 5 │ [test] │ dir │ 192 B │ 30 seconds ago │
│ 6 │ [test]/a │ file │ 0 B │ 30 seconds ago │
│ 7 │ [test]/b │ file │ 0 B │ 30 seconds ago │
│ 8 │ [test]/c │ file │ 0 B │ 30 seconds ago │
│ 9 │ [test]/d │ file │ 0 B │ 30 seconds ago │
│ 10 │ a │ file │ 0 B │ 4 minutes ago │
│ 11 │ b │ file │ 0 B │ 4 minutes ago │
│ 12 │ c │ file │ 0 B │ 4 minutes ago │
│ 13 │ d │ file │ 0 B │ 4 minutes ago │
│ 14 │ e │ file │ 0 B │ 4 minutes ago │
│ 15 │ f │ file │ 0 B │ 4 minutes ago │
│ 16 │ g │ file │ 0 B │ 4 minutes ago │
╰────┴──────────┴──────┴───────┴────────────────╯
❯ cd *; rm a; cd ..; ls **/*
╭────┬──────────┬──────┬───────┬───────────────╮
│ # │ name │ type │ size │ modified │
├────┼──────────┼──────┼───────┼───────────────┤
│ 0 │ * │ dir │ 160 B │ now │
│ 1 │ */b │ file │ 0 B │ a minute ago │
│ 2 │ */c │ file │ 0 B │ a minute ago │
│ 3 │ */d │ file │ 0 B │ a minute ago │
│ 4 │ [test] │ dir │ 160 B │ now │
│ 5 │ [test]/b │ file │ 0 B │ a minute ago │
│ 6 │ [test]/c │ file │ 0 B │ a minute ago │
│ 7 │ [test]/d │ file │ 0 B │ a minute ago │
│ 8 │ a │ file │ 0 B │ 4 minutes ago │
│ 9 │ b │ file │ 0 B │ 4 minutes ago │
│ 10 │ c │ file │ 0 B │ 4 minutes ago │
│ 11 │ d │ file │ 0 B │ 4 minutes ago │
│ 12 │ e │ file │ 0 B │ 4 minutes ago │
│ 13 │ f │ file │ 0 B │ 4 minutes ago │
│ 14 │ g │ file │ 0 B │ 4 minutes ago │
╰────┴──────────┴──────┴───────┴───────────────╯How to reproduce
mkdir * a b c dtouch */a */b */c */d a/a b/a c/a d/acd *; rm a
Expected behavior
Only delete */a
Screenshots
No response
Configuration
| column0 | column1 |
|---|---|
| version | 0.84.1 |
| branch | master |
| commit_hash | e514535 |
| build_os | macos-aarch64 |
| build_target | aarch64-apple-darwin |
| rust_version | rustc 1.70.0 (90c541806 2023-05-31) |
| rust_channel | 1.70.0-aarch64-apple-darwin |
| cargo_version | cargo 1.70.0 (ec8a8a0ca 2023-04-25) |
| build_time | 2023-09-04 09:41:32 +09:00 |
| build_rust_channel | release |
| allocator | standard |
| features | dataframe, default, extra, sqlite, trash, wasi, which, zip |
| installed_plugins | query, query json, query web, query xml |
Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A:coreutils-uutilsChanges relating to coreutils/uutilsChanges relating to coreutils/uutilsA:file-systemRelated to commands and core nushell behavior around the file systemRelated to commands and core nushell behavior around the file systemA:globBehavior around file-system globbing with regular commands or `glob`. See also A:quoting/expansionBehavior around file-system globbing with regular commands or `glob`. See also A:quoting/expansion