Skip to content

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

Closed

Description

@coiby

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

Activity

  1. mvdan commented on Oct 19, 2024

    @mvdan
    Owner

    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.

  2. added a commit that references this issue on Oct 19, 2024
    25c0048
  3. coiby commented on Oct 22, 2024

    @coiby
    Author

    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?

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

      ⌂ 换网址