nushell/crates/nu-engine/src
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
..
call_ext.rs IO and redirection overhaul (#11934) 2024-03-14 15:51:55 -05:00
column.rs Use Record's public API in a bunch of places (#10927) 2023-11-08 14:24:00 +01:00
documentation.rs IO and redirection overhaul (#11934) 2024-03-14 15:51:55 -05:00
env.rs Make EngineState clone cheaper with Arc on all of the heavy objects (#12229) 2024-03-19 19:07:00 +01:00
eval_helpers.rs IO and redirection overhaul (#11934) 2024-03-14 15:51:55 -05:00
eval.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
glob_from.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
lib.rs Debugger experiments (#11441) 2024-03-08 20:21:35 +02:00
scope.rs Keep plugins persistently running in the background (#12064) 2024-03-09 17:10:22 -06:00