mvdan / sh

A shell parser, formatter, and interpreter with bash support; includes shfmt
https://pkg.go.dev/mvdan.cc/sh/v3
BSD 3-Clause "New" or "Revised" License
7.27k stars 345 forks source link

Breaks with string: echo 'test' > /var/spool/fcron/{{ USERNAME }}.orig #836

Closed yonas closed 2 years ago

yonas commented 2 years ago

shfmt breaks with this string:

# cat test.sh
echo 'test' > /var/spool/fcron/{{ USERNAME }}.orig

# cat test.sh | shfmt
echo 'test' USERNAME }}.orig >/var/spool/fcron/{{

shfmt v3.4.3 FreeBSD 13.0-RELEASE-p10

mvdan commented 2 years ago

Are you sure your shell is valid? /var/spool/fcron/{{ USERNAME }}.orig is three words, not one, hence why shfmt reformats it that way.

yonas commented 2 years ago

Thanks, it's a template, not valid shell yet.

I'll run jinja over it first, and then shfmt. Thanks!