News for hackers. Stuff that matters.
Re:Dockerfmt: A Dockerfile Formatter by mdaniel on Tuesday April 08, 2025 @11:58PM (#43628765)
waaaat? https://github.com/reteps/dockerfmt#:~:text=The%20RUN%20pars...

I am firmly in the camp of

  RUN set -e ;\
      export DEBIAN_FRONTEND=noninteractive ;\
      etc etc
so I guess this tool isn't for me
Re:Dockerfmt: A Dockerfile Formatter by spicypete on Wednesday April 09, 2025 @12:20AM (#43628837)
Is there any reason you prefer `set -e` over `&&`? I'm curious if this is a readability thing.
Re:Dockerfmt: A Dockerfile Formatter by figmert on Wednesday April 09, 2025 @02:54AM (#43629518)
I'm firmly in that camp but I also always add `set -eux`, which makes it so much better at debugging as that gives you individual commands it runs before the output of them.
Re:Dockerfmt: A Dockerfile Formatter by figmert on Wednesday April 09, 2025 @07:26AM (#43630958)
To be clear, the difference is something along this line:

    $ bash -ec 'echo hello && ls -la /tmp/ | grep systemd && false && echo testing'
    hello
    drwx------.   3 root   root      60 Mar 29 18:33 systemd-private-bluetooth.service-yuSMVM
    drwx------.   3 root   root      60 Mar 29 18:33 systemd-private-upower.service-YhHHP2
versus

    $ bash -euxc 'echo hello; ls -la /tmp/ | grep systemd; false; echo testing'
    + echo hello
    hello
    + ls -la /tmp/
    + grep systemd
    drwx------.   3 root   root      60 Mar 29 18:33 systemd-private-bluetooth.service-yuSMVM
    drwx------.   3 root   root      60 Mar 29 18:33 systemd-private-upower.service-YhHHP2
    + false
Docker also supports the `SHELL` syntax now, which is even better, because you can set it once at the top of the Dockerfile without having to do the whole `set -eux` on every line.
Re:Dockerfmt: A Dockerfile Formatter by mdaniel on Wednesday April 09, 2025 @09:49AM (#43632075)
Readability is putting it mildly; do you write your shell scripts using that && style? No? Why not, is it for readability?

I also have a hard time reasoning about && with anything other than the most braindead sequence of commands because: $(thing && if other_thing; then inner_thing1 && thing2; fi && ohgawd)

And I just realized while typing that out that if its parser doesn't support ; then I guess one needs to

  RUN if conditional_thing \
      then good_luck && \
      fi && \
      echo "whew"
Re:Dockerfmt: A Dockerfile Formatter by spicypete on Wednesday April 09, 2025 @12:13PM (#43633727)
This is a valid point -- I replied to why this is the way it is her: https://news.ycombinator.com/item?id=43629049. I understand it's not ideal for many, and I am open to PRs!
Re:Dockerfmt: A Dockerfile Formatter by rgovostes on Wednesday April 09, 2025 @01:09AM (#43629061)
As far as I can tell from https://github.com/moby/moby/issues/4032, as of Debian 12 "bookworm" and Ubuntu 23.04 "Lunar", explicitly setting DEBIAN_FRONTEND is no longer necessary.