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

'|' can only immediately follow a statement #665

Closed
bitfrei opened this issue Feb 14, 2021 · 2 comments
Closed

'|' can only immediately follow a statement #665

bitfrei opened this issue Feb 14, 2021 · 2 comments

Comments

@bitfrei
Copy link

bitfrei commented Feb 14, 2021

Hi, I'm using shfmt not directly, but with shell-format.

For some files, I get errors when using pipelines / pipes with ('|'):
| can only immediately follow a statement

A simple example would be:

#!/bin/bash
echo "hello" \
        | tee 

It seems shfmt is not handling the line break properly as this one works:

#!/bin/bash
echo "hello" | \
        tee 

Albeit being a legit option I would prefer the first solution.
Also shfmt does not intend tee.., which should be the case?

@mvdan
Copy link
Owner

mvdan commented Feb 15, 2021

It almost sounds like there's a bug in shell-format, because shfmt works just fine with what you provided:

$ cat f.sh
#!/bin/bash
echo "hello" \
        | tee
$ shfmt f.sh
#!/bin/bash
echo "hello" |
	tee
$ shfmt -bn f.sh
#!/bin/bash
echo "hello" \
	| tee
$ shfmt -version
v3.3.0-0.dev.0.20210203135509-56c9918c980d

@bitfrei
Copy link
Author

bitfrei commented Feb 15, 2021

ok. Well, I couldn't test it with shfmt alone, so sorry and thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants