nushell / nushell

A new type of shell
https://www.nushell.sh/
MIT License
32.44k stars 1.67k forks source link

Cannot use command output as argument when the command includes `#` #13810

Open honnip opened 2 months ago

honnip commented 2 months ago

Describe the bug

For example, I cannot nix path-info -Sh (nix build --print-out-paths nixpkgs#nushell)

How to reproduce

  1. type nix path-info -Sh (nix build --print-out-paths nixpkgs#nushell)
  2. enter
  3. it does not executed, and the cursor moves on to the next line.

Expected behavior

executes the command inside, then passes it as argument

Configuration

key value
version 0.97.1
major 0
minor 97
patch 1
branch
commit_hash
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.80.1 (3f5fd8dd4 2024-08-06) (built from a source tarball)
cargo_version cargo 1.80.0 (376290515 2024-07-16)
build_time 1980-01-01 00:00:00 +00:00
build_rust_channel release
allocator mimalloc
features default, sqlite, system-clipboard, trash
installed_plugins
kubouch commented 2 months ago

This might be a bug because IIRC we made it so that comments would need whitespace before the # to specifically allow these use cases. For example:

^echo foo#bar

works, but

^echo (^echo foo#bar)

doesn't. So, clearly, there is some mismatch.

Doing nix path-info -Sh (nix build --print-out-paths 'nixpkgs#nushell') should work as a workaround.

sholderbach commented 2 months ago

Yeah something is amiss in the parser after encountering a #, breaking the validation even though we only treat it as a comment with a leading space