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

Running format breaks Dockerfiles #29

Closed
mrbrownt opened this issue Mar 1, 2019 · 6 comments
Closed

Running format breaks Dockerfiles #29

mrbrownt opened this issue Mar 1, 2019 · 6 comments

Comments

@mrbrownt
Copy link

mrbrownt commented Mar 1, 2019

When running format on Dockerfiles it removes all of the \ and line endings. This causes RUN commands in docker build to not work.

Runnning shell-format 4.0.4 and shfmt 2.6.3

@foxundermoon
Copy link
Owner

foxundermoon commented Mar 1, 2019

can you paste your dockerfile content?

@JounQin
Copy link

JounQin commented Oct 11, 2019

mvdan/sh#424

@foxundermoon It seems Dockerfile is actually not supported by shfmt officially.

br3ndonland added a commit to br3ndonland/dotfiles that referenced this issue Sep 18, 2020
foxundermoon/vs-shell-format#29
foxundermoon/vs-shell-format#62
mvdan/sh#424

The foxundermoon/vs-shell-format extension formats Dockerfiles, but it
shouldn't, because the underlying formatter mvdan/sh isn't engineered
for Dockerfiles. As explained in mvdan/sh#424,

> Removing the `\` is correct in shell, because a line ending in `&&`
> just continues the command in the following line.

This commit will disable Dockerfile formatting.
br3ndonland added a commit to br3ndonland/dotfiles that referenced this issue Nov 6, 2020
foxundermoon/vs-shell-format#29
foxundermoon/vs-shell-format#62
mvdan/sh#424

The foxundermoon/vs-shell-format extension formats Dockerfiles, but it
shouldn't, because the underlying formatter mvdan/sh isn't engineered
for Dockerfiles. As explained in mvdan/sh#424,

> Removing the `\` is correct in shell, because a line ending in `&&`
> just continues the command in the following line.

This commit will disable Dockerfile formatting.
@mattt
Copy link

mattt commented Mar 24, 2021

@foxundermoon Please consider reopening and addressing this issue. When this extension is installed, format-on-save breaks Dockerfiles containing any backslashes (see mvdan/sh#424 as mentioned by @JounQin).

@JounQin
Copy link

JounQin commented Mar 24, 2021

@mattt binaryNextLine is auto enabled in prettier-plugin-sh, you can use it if you are using prettier.

@Pointotech
Copy link

If this formatter doesn't support Dockerfiles, why is it formatting Dockerfiles?

@JukMR
Copy link

JukMR commented Jan 4, 2024

Same issue here, this breaks my dockerfiles. It is very problematic that this extensions causes this and that the issue is not resolved yet.

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

6 participants