Skip to content

Unexpected interpolation in argument for script #7936

@mksinicus

Description

@mksinicus

Describe the bug

When a non-interpolated string containing ( or () is passed to a nu script file, nu tries to interpolate it, if none of the parentheses are adjacent to or contain a whitespace or a (already escaped) backslash.

How to reproduce

  1. "#!/usr/bin/env nu\ndef main [str] {echo $str}" | save test; chmod +x test
  2. ./test '(aaaa)' yields the external command failed error (assuming there is no real command called aaaa)
  3. '(aa aa)', '( aaaa)', ' (aaaa)', '\(aaaa)' vel sim. are just printed
  4. However, "(date\tnow)" will print like $"(date now)"

Expected behavior

I expect nu to treat these strings in accordance with the expected behavior as documented

Screenshots

Screenshot_20230201_215732

Screenshot_20230201_215756

Since ($env.config) didn't print the config record, it probably is a problem in the nu process that runs the script, not the shell

Configuration

key value
version 0.75.0
branch
commit_hash
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.65.0 (897e37553 2022-11-02)
rust_channel stable-x86_64-unknown-linux-gnu
cargo_version cargo 1.65.0 (4bc8f24d3 2022-10-20)
pkg_version 0.75.0
build_time 2023-02-01 07:12:44 +08:00
build_rust_channel release
features database, dataframe, default, trash, which, zip
installed_plugins

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:quoting-expansionIssues related to string quoting, interpolation, and expansion of variable or glob patterns

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions