Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
nicki-krizek opened this issue Oct 26, 2023 · 1 comment

Comments

@nicki-krizek
Copy link

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
@nicki-krizek nicki-krizek changed the title backslahes may be incorrectly escaped when converting to $(...) notation backslashes may be incorrectly escaped when converting to $(...) notation Oct 26, 2023
manu0x0 pushed a commit to isc-projects/bind9 that referenced this issue Oct 26, 2023
Backslashes weren't handled properly when formatting the code with
shfmt.

Related mvdan/sh#1041
@mvdan
Copy link
Owner

mvdan commented Nov 12, 2023

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.

@mvdan mvdan 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 Nov 12, 2023
@mvdan mvdan closed this as completed in 3384f3d Dec 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants