History expansion (!!) triggers inside backtick-quoted strings, corrupting file paths

Open
#1,056 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
58/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
rust
Domain
cli

Research direction

Reproduce the reported command after creating a filename containing !! and adding a history entry. Trace how history expansion and backtick quoting are handled, then verify that the quoted path remains literal and add regression coverage for the example behavior.

Written by the indexing model from the issue text.

Description

Bug report form
  • I have done a basic search of the issue tracker to find any existing issues that are similar.
  • I have checked that my version is at least the latest stable release available via my installation method.
Describe the bug

When a filename contains !!, Nushell performs history expansion on it even when the name is wrapped in backticks. Since backticks are a quoting form, no history expansion should occur inside them. The result is that the token is silently rewritten to a different path before the command executes, making the real file impossible to reference by name.

Bug outcome:
On Enter, the command line is rewritten to ls test & test ls test.txt — !! has been expanded to the first token of the previous command (ls). The backticks did not prevent the expansion. The command then fails or targets the wrong path, and the actual file on disk cannot be addressed via its real name.

How to reproduce
  1. Create a file whose name contains !!, e.g. test & test !! test.txt.
  2. Run any command, e.g. ls, so that history has at least one entry.
  3. Type: ls test & test !! test.txt and press Enter.
Expected behavior

The backtick-quoted string is passed through literally. ls (or rm, open, etc.) operates on the file test & test !! test.txt. This matches how Bash and Zsh handle history expansion inside single quotes.

Configuration

version │ 0.112.2
major │ 0
minor │ 112
patch │ 2
branch │
commit_hash │ d80ee8c19e07a8058e50a30a4205d3e97068f585
build_os │ windows-x86_64
build_target │ x86_64-pc-windows-msvc
rust_version │ rustc 1.92.0 (ded5c06cf 2025-12-08)
rust_channel │ 1.92.0-x86_64-pc-windows-msvc
cargo_version │ cargo 1.92.0 (344c4567c 2025-10-21)
build_time │ 2026-04-15 21:31:35 +00:00
build_rust_channel │ release
allocator │ standard
features │ default, mcp, network, plugin, rustls-tls, sqlite, trash-support
installed_plugins │
experimental_options │ example=false, reorder-cell-paths=true, pipefail=true, enforce-runtime-annotations=false, native-clip=false, cell-path-types=false

Dominant language
Rust
Stars
818
Forks
249
Avg merge
4d 14h
Merged PRs (30d)
30

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.

More from nushell/reedline

All issues in nushell/reedline

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.