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

trailing whitespace added at the start of a multi-line if condition #1104

Open
bradzacher opened this issue Oct 28, 2024 · 1 comment
Open

Comments

@bradzacher
Copy link

Input

if [[
  true ]]; then
  echo 1
fi

Expected

if [[
  true ]]; then
  echo 1
fi

Actual

if [[ 
  true ]]; then
  echo 1
fi

Note the trailing whitespace after the [[

Repro command

$ shfmt --version
3.10.0
$ shfmt --indent 2 --write /tmp/foo.sh

Additional Information

Ignore the fact that true could fit on one line -- the real code is a condition long enough to require line breaks to fit.
It's worth noting that part of me was also surprised that shfmt doesn't emit if [[ true ]] -- but that's separate to the issue of a trailing whitespace.

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

4 participants
@bradzacher and others