Skip to content

Bashisms don't work when typing string arguments #18315

Closed

Description

@132ikl

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

If you type !! or !$ when typing a command with string arguments, they are not properly expanded

Bisected to #18197 (cc @casedami, @fdncred)

How to reproduce

  1. Type echo hi and press enter
  2. Type echo !$ or echo !! and press enter
    The second command will output !$/!!

Expected behavior

The !$/!! should be expanded, making the result of the second command hi/echo hi

Configuration

key value
version 0.113.1
major 0
minor 113
patch 1
branch makepkg
commit_hash 7b7df4a
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.95.0 (59807616e 2026-04-14) (Arch Linux rust 1:1.95.0-1)
cargo_version cargo 1.95.0 (f2d3ce0bd 2026-03-21) (Arch Linux rust 1:1.95.0-1)
build_time 2026-05-30 01:03:10 +00:00
build_rust_channel release
allocator standard
features default, mcp, network, plugin, rustls-tls, sqlite, trash-support
installed_plugins custom_values 0.1.0, example 0.111.1-nightly.31, explore_ir 0.6.0, formats 0.111.1-nightly.31, gstat 0.111.1-nightly.31, inc 0.111.1-nightly.31, polars 0.111.1-nightly.31, query 0.111.1-nightly.31, stress_internals 0.111.1-nightly.31
experimental_options example=false, reorder-cell-paths=true, pipefail=true, enforce-runtime-annotations=true, native-clip=true, cell-path-types=true

Activity

  1. added
    category:bug
    A:line-editor
    status:needs-triage
    category:regression
    and removed
    category:bug
    on May 30, 2026
  2. casedami commented on May 30, 2026

    @casedami
    Contributor

    My initial guess as to the cause would be the expansions being parsed as ExternalArg and therefore is_inside_string_literal is returning True

  3. fdncred commented on May 31, 2026

    @fdncred
    Contributor

    That stinks! @casedami Can you take a closer look when you have time? It makes me think we don't have any bashism tests too. 🤔

  4. casedami commented on May 31, 2026

    @casedami
    Contributor

    Sure, i can investigate the bashism tests also

  5. fdncred commented on May 31, 2026

    @fdncred
    Contributor

    Sure, i can investigate the bashism tests also

    Thank you. It's much appreciated!

  6. casedami commented on Jun 2, 2026

    @casedami
    Contributor

    for context, right now this behavior comes from

    // reedline/scr/engine.rs line 1790
    fn try_expand_abbreviation_at_cursor(&mut self, submitted: bool) -> Option<ReedlineEvent> {
            ...
            if self
                .highlighter
                .is_inside_string_literal(buffer, word_start)
            {
                return None;
            }
            ...

    where within is_inside_string_literal we added FlatShape::ExternalArg to the match statement

    // nushell/crates/nu-cli/src/syntax_highlight.rs
    fn is_inside_string_literal(&self, line: &str, cursor: usize) -> bool {
      ...
      span.contains(global_cursor)
        && matches!(
          shape,
          FlatShape::String
          | FlatShape::RawString
          | FlatShape::StringInterpolation
          | FlatShape::ExternalArg
        )

    we want to decouple string detection from external arg detection as far as expanding abbreviations go. correct me if im wrong: for bashism abbreviations, i think we don't want expansion within a string but we do want it as an external arg; for fish-style abbreviations we don't want expansions for either.

    so i think there are two ways to go about this:

    1. add another function to the Highlighter trait, something like is_external_arg
    2. rename is_inside_string_literal to something like should_expand_abbr which would take a parameter defining the union of FlatShape that would veto an abbreviation expansion

    then each expansion type can define when they expand/dont expand accordingly

  7. fdncred commented on Jun 3, 2026

    @fdncred
    Contributor

    Option 2 sounds best to me. Thanks for looking into this.

  8. casedami commented on Jun 3, 2026

    @casedami
    Contributor

    Np, I can submit PRs for this sometime this week

  9. added a commit that references this issue on Jun 11, 2026
    5e6e1a6
  10. added this to the v0.114.0 milestone on Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:line-editorcategory:regressionstatus:needs-triage

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions