nushell/crates/nu-protocol/src/value
Wind 87c5f6e455
ls, rm, cp, open, touch, mkdir: Don't expand tilde if input path is quoted string or a variable. (#12232)
# Description
Fixes:  #11887
Fixes: #11626

This pr unify the tilde expand behavior over several filesystem relative
commands. It follows the same rule with glob expansion:
|  command  |  result |
| ----------- |  ------ |
| ls ~/aaa  | expand tilde
| ls "~/aaa"  | don't expand tilde
| let f = "~/aaa"; ls $f | don't expand tilde, if you want to: use `ls
($f \| path expand)`
| let f: glob = "~/aaa"; ls $f | expand tilde, they don't expand on
`mkdir`, `touch` comamnd.

Actually I'm not sure for 4th item, currently it's expanding is just
because it followes the same rule with glob expansion.

### About the change
It changes `expand_path_with` to accept a new argument called
`expand_tilde`, if it's true, expand it, if not, just keep it as `~`
itself.

# User-Facing Changes
After this change, `ls "~/aaa"` won't expand tilde.

# Tests + Formatting
Done
2024-03-25 10:08:38 +08:00
..
custom_value.rs Misc doc fixes (#12266) 2024-03-23 07:26:08 -05:00
duration.rs Restructure nu-protocol in more meaningful units (#11917) 2024-03-10 18:45:45 +01:00
filesize.rs Restructure nu-protocol in more meaningful units (#11917) 2024-03-10 18:45:45 +01:00
from_value.rs open, rm, umv, cp, rm and du: Don't globs if inputs are variables or string interpolation (#11886) 2024-02-23 09:17:09 +08:00
from.rs Spanned Value step 1: span all value cases (#10042) 2023-08-25 08:48:05 +12:00
glob.rs ls, rm, cp, open, touch, mkdir: Don't expand tilde if input path is quoted string or a variable. (#12232) 2024-03-25 10:08:38 +08:00
lazy_record.rs Create Record type (#10103) 2023-08-25 07:50:29 +12:00
mod.rs Add test support crate for plugin developers (#12259) 2024-03-23 13:29:54 -05:00
path.rs open, rm, umv, cp, rm and du: Don't globs if inputs are variables or string interpolation (#11886) 2024-02-23 09:17:09 +08:00
range.rs Auto format let-else block (#10214) 2023-09-04 19:42:31 +12:00
record.rs Remove Record::from_raw_cols_vals_unchecked (#11810) 2024-02-18 14:20:22 +02:00