nushell/crates/nu-command/src/path
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
..
basename.rs Add long options for path (#10775) 2023-10-19 22:07:01 +02:00
dirname.rs Add long options for path (#10775) 2023-10-19 22:07:01 +02:00
exists.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
expand.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
join.rs Add Value::coerce_str (#11885) 2024-02-18 17:47:10 +01:00
mod.rs Move Value to helpers, separate span call (#10121) 2023-09-03 07:27:29 -07:00
parse.rs Convert more examples and tests to record! macro (#10840) 2023-10-28 14:52:31 +02:00
path_.rs Move Value to helpers, separate span call (#10121) 2023-09-03 07:27:29 -07:00
relative_to.rs Enforce required, optional, and rest positional arguments start with an uppercase and end with a period. (#11285) 2023-12-15 14:32:37 +08:00
split.rs Move Value to helpers, separate span call (#10121) 2023-09-03 07:27:29 -07:00
type.rs Allow parse-time evaluation of calls, pipelines and subexpressions (#9499) 2023-08-26 16:41:29 +03:00