Skip to content

Quotes in external command string parameter being escaped when they shouldn't be #1957

Closed

Description

@taylorthurlow

Using string command parameters (--thing="value") is escaping the quotes in the value.

To Reproduce

> git --git-dir=.git rev-parse --show-toplevel
/my/project

> git --git-dir=".git" rev-parse --show-toplevel
fatal: not a git repository: '".git"'

Note the double quotes surrounding the --git-dir parameter in the second example.

Expected behavior
Both examples are functionally the same - I should be able to surround the string with quotes, and they should not be escaped (included as part of the value itself).

Configuration (please complete the following information):

  • OS: macOS 10.15.5
  • Nu version: 0.15.0
  • Optional features (if any): All stable features

Activity

  1. added
    category:bug
    A:external-commands
    on Jun 10, 2020
  2. kstrohbeck commented on Jun 18, 2020

    @kstrohbeck

    When processing a command, it looks like the remove_quotes function is used to remove quotes from arguments, but it only strips them from the outside. From testing, most other shells (testing PowerShell, sh, bash, csh, and zsh) allow quotes in any part of the argument to be stripped (so even something like --git-di"r=.gi"t would be transformed to --git-dir=.git.)

    In fact, all of those shells allow and strip quotes anywhere; e"cho" h"el"lo is equivalent to echo hello. It seems like to cover all these cases, the change should be made in either lite_parse or parse (or both,) but I'm not sure which one (or if nushell even wants to be consistent in this way.)

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:external-commandscategory:bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions