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

shfmt still complains that " &> redirects are a bash/mksh feature" although it parses the script as bash #1102

Closed
coiby opened this issue Oct 14, 2024 · 2 comments

Comments

@coiby
Copy link

coiby commented Oct 14, 2024

Problem

shfmt makes the following complaint,

&> redirects are a bash/mksh feature (parsed as bash via -ln=auto)

which doesn't sound reasonable to me because the script is already parsed as bash

How to reproduce it

cat << 'EOF' > test.sh
#!/bin/bash
echo test 1 &>2
EOF


cat << 'EOF' > .editorconfig
root = true

[*]
shell_variant = posix
EOF

if ! shfmt -d test.sh; then
    echo "test failed"
fi
@mvdan
Copy link
Owner

mvdan commented Oct 19, 2024

Thanks for reporting this. As far as I can tell, the behavior in terms of parsing is correct - shell_variant = posix is applied from EditorConfig like a -ln=posix flag, so you are actually parsing in POSIX mode. It's the error message which is wrong and very confusing. I've fixed that now.

@coiby
Copy link
Author

coiby commented Oct 22, 2024

Thanks for coming up with a fix quickly!

I have one question. In the reproducer, the shebang is !/bin/bash. So do you imply EditConfig will overwrite shebang?

This was referenced Nov 16, 2024
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