nushell / nushell/nushell

Backticked strings getting unexpectedly executed as external commands

Open
#11,713 5 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A:quoting-expansion category:confusing status:needs-triage
Dominant language
Rust
Stars
40.5k
Forks
2.3k
Avg merge
1d 19h
Merged PRs (30d)
85

Description

Describe the bug

According to the docs "Working with strings", backticks are one of the ways to create a string. Let's try:

~: let a = "hello" + "world" ; $a
helloworld
~: let a = "hello" + `world` ; $a
helloworld
~: let a = `hello` + "world" ; $a
Error: nu::shell::external_command

  × External command failed
   ╭─[entry #32:1:1]
 1 │ let a = `hello` + "world" ; $a
   ·         ───┬───
   ·            ╰── executable was not found
   ╰────
  help: No such file or directory (os error 2)

This can lead to counter-intuitive things like:

$ cat ~/bin/wipeeverything
#!/usr/bin/env bash
#rm -rf /
echo "Wiping everything"

$ cat supertool.nu
let messages = [`hello` `world`] # creating strings
let message = `wipeeverything` # creating string (big mistake)
let combined = $messages | append $message
$combined

$ nu supertool.nu
╭───┬───────────────────╮
│ 0 │ hello             │
│ 1 │ world             │
│ 2 │ Wiping everything │
╰───┴───────────────────╯
How to reproduce

See description.

Expected behavior

If it's one of the ways to create strings, then it should behave like all other strings. If let a = "hello" + "world" doesn't run the hello executable, then neither should let a = `hello` + "world".

Screenshots

No response

Configuration
key value
version 0.89.0
branch
commit_hash
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.75.0 (82e1608df 2023-12-21)
rust_channel stable-x86_64-unknown-linux-gnu
cargo_version cargo 1.75.0 (1d8b05cdd 2023-11-20)
build_time 2024-02-01 13:42:12 +01:00
build_rust_channel release
allocator mimalloc
features default, sqlite, trash, which, zip
installed_plugins
Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the behavior from the issue using nu supertool.nu and the backtick examples, then read the documented “Working with strings” behavior alongside the command execution path. Done means backticked values in concatenations and lists remain strings and do not execute matching external commands, while the existing string examples continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.