nushell/crates/nu-parser/src
Devyn Cairns 0e1553026e
Restore tilde expansion on external command names (#13001)
# Description

Fix a regression introduced by #12921, where tilde expansion was no
longer done on the external command name, breaking things like

```nushell
> ~/.cargo/bin/exa
```

This properly handles quoted strings, so they don't expand:

```nushell
> ^"~/.cargo/bin/exa"
Error: nu:🐚:external_command

  × External command failed
   ╭─[entry #1:1:2]
 1 │ ^"~/.cargo/bin/exa"
   ·  ─────────┬────────
   ·           ╰── Command `~/.cargo/bin/exa` not found
   ╰────
  help: `~/.cargo/bin/exa` is neither a Nushell built-in or a known external command

```

This required a change to the parser, so the command name is also parsed
in the same way the arguments are - i.e. the quotes on the outside
remain in the expression. Hopefully that doesn't break anything else. 🤞

Fixes #13000. Should include in patch release 0.94.1

cc @YizhePKU

# User-Facing Changes
- Tilde expansion now works again for external commands
- The `command` of `run-external` will now have its quotes removed like
the other arguments if it is a literal string
- The parser is changed to include quotes in the command expression of
`ExternalCall` if they were present

# Tests + Formatting
I would like to add a regression test for this, but it's complicated
because we need a well-known binary within the home directory, which
just isn't a thing. We could drop one there, but that's kind of a bad
behavior for a test to do. I also considered changing the home directory
for the test, but that's so platform-specific - potentially could get it
working on specific platforms though. Changing `HOME` env on Linux
definitely works as far as tilde expansion works.

- 🟢 `toolkit fmt`
- 🟢 `toolkit clippy`
- 🟢 `toolkit test`
- 🟢 `toolkit test stdlib`
2024-05-29 18:48:29 -07:00
..
deparse.rs update deps calamine and quick-xml (#11582) 2024-01-19 12:23:51 -06:00
exportable.rs Restructure nu-protocol in more meaningful units (#11917) 2024-03-10 18:45:45 +01:00
flatten.rs Fix syntax highlighting for not (#12815) 2024-05-10 07:09:44 +08:00
known_external.rs Use CommandType in more places (#12832) 2024-05-18 23:37:31 +00:00
lex.rs make better messages for incomplete string (#12868) 2024-05-15 01:14:11 +00:00
lib.rs IO and redirection overhaul (#11934) 2024-03-14 15:51:55 -05:00
lite_parser.rs Fix panic when redirecting nothing (#12970) 2024-05-27 10:03:06 +08:00
parse_keywords.rs Use CommandType in more places (#12832) 2024-05-18 23:37:31 +00:00
parse_patterns.rs Add command_prelude module (#12291) 2024-03-26 21:17:30 +00:00
parse_shape_specs.rs Add command_prelude module (#12291) 2024-03-26 21:17:30 +00:00
parser.rs Restore tilde expansion on external command names (#13001) 2024-05-29 18:48:29 -07:00
parser_path.rs Deprecate register and add plugin use (#12607) 2024-04-23 06:37:50 -05:00
type_check.rs Shrink the size of Expr (#12610) 2024-04-24 15:46:35 +00:00