Skip to content

syntax: converting a backtick command substitution with escaped characters leaves too many backslashes #1041

Closed

Description

@nicki-krizek

shfmt 3.7.0 incorrectly escapes backslashes in the following example:

### input
x=`echo "1.2" | sed -e 's/\./\\\\./g'`
echo $x # prints out 1\.2

### actual output
x=$(echo "1.2" | sed -e 's/\./\\\\./g')
echo $x # prints out 1\\.2

### expected output
x=$(echo "1.2" | sed -e 's/\./\\./g')
echo $x # prints out 1\.2

Activity

  1. changed the title [-]backslahes may be incorrectly escaped when converting to $(...) notation[/-] [+]backslashes may be incorrectly escaped when converting to $(...) notation[/+] on Oct 26, 2023
  2. mvdan commented on Nov 12, 2023

    @mvdan
    Owner

    Thanks - this sounds like a bug. We probably never noticed given that it's a relatively rare edge case. Happy to review a PR with a test.

  3. changed the title [-]backslashes may be incorrectly escaped when converting to $(...) notation[/-] [+]syntax: converting a backtick command substitution with escaped characters leaves too many backslashes[/+] on Nov 12, 2023
  4. added a commit that references this issue on Feb 13, 2024
    3384f3d
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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址