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: places ";then" on wrong line when using heredoc as stdin for a command #1047

Open
dionysius opened this issue Dec 7, 2023 · 0 comments

Comments

@dionysius
Copy link

dionysius commented Dec 7, 2023

shfmt v3.6.0

Before:

#!/bin/bash

if ! lxc launch --vm "$image" "$name" <<EOF
${instance_config}
EOF
then
        lxc delete -f "$name"
fi

After:

#!/bin/bash

if ! lxc launch --vm "$image" "$name" <<EOF; then
${instance_config}
EOF
        lxc delete -f "$name"
fi

It breaks the script and modifies the heredoc content. It should not move the then and keep it on his own line without prepended ;.

Note: Putting the command into the if is recommended by SC2181. Obviously <<<"${instance_config}" can be used but the issue is still present when using heredoc.

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

1 participant