language-docker icon indicating copy to clipboard operation
language-docker copied to clipboard

syntax highlight && when used in RUN commands?

Open sandywater opened this issue 9 years ago • 11 comments

I think it would make for some beautiful Dockerfiles.

Also I have forgotten an && or a \ at the end of a line only to have a 20 min build fail at the last second due to that.

maybe the regex would be ^&& or && \

sandywater avatar Aug 10 '16 00:08 sandywater

This would be a nice compliment to the / highlighting we just added. PRs welcome, otherwise I'll have a look in due course.

jagregory avatar Aug 10 '16 01:08 jagregory

It would make more sense to add shellcheck support instead, by using syntax shell for [ON BUILD] RUN commands.

mishak87 avatar Aug 10 '16 09:08 mishak87

@jagregory @mishak87, what do you think about this one?

I inlined the shellscript grammar into the RUN <shell> expression, and also made a support of \.

xamgore avatar Jun 02 '17 09:06 xamgore

I think that looks great! On Fri, 2 Jun 2017 at 7:22 pm, Igor Strebezhev [email protected] wrote:

@jagregory https://github.com/jagregory @mishak87 https://github.com/mishak87, what do you think about this one?

https://cloud.githubusercontent.com/assets/4586392/26719467/5123e182-478d-11e7-9fe8-975b8d288642.png

I inlined the shellscript grammar into the RUN expression, and also made a support of .

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/jagregory/language-docker/issues/21#issuecomment-305736257, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAqTIn06ktMaTFRHCNSt-4GtRgriJVXks5r_9RlgaJpZM4Jgqpn .

jagregory avatar Jun 02 '17 12:06 jagregory

@xamgore Could you also please add syntax--operator for the &&? I would love to syntax highlight them a bit differently than echo and test in the examples

klippx avatar Jun 08 '17 07:06 klippx

@klippx, there are two ways here. The first one it to make a pull request to the language-shell package. The second one is just to drop the inner shell scope I have made, in favor of self written implementation. I'm not sure what is the best one.

xamgore avatar Jun 08 '17 08:06 xamgore

@xamgore I think flagging the thing as syntax--shell is the best solution, go for it! Did you already pull request it?

klippx avatar Jun 08 '17 13:06 klippx

@klippx not yet. I want to check whether docker accepts the command with newlines:

RUN for (( i = 0; i < 10; i++ )); do
      echo $i;
done

If it turns out that no, but Atom still hightlights it, then… I will need some time to fix this.

xamgore avatar Jun 11 '17 10:06 xamgore

@xamgore End of line slashes are docker proprietary format. They have nothing to do with shell slashes (command continues on next line). Docker simply join lines together.

RUN a \
b \
  c

Results in:

sh -c 'a_b___c'

Note: I have replaced spaces with undescores to more clearly demonstrate what is happening

mishak87 avatar Jun 12 '17 09:06 mishak87

Still no support for shell syntax highlighting in language-docker? That would be pretty cool.

ariasuni avatar Apr 06 '18 17:04 ariasuni

Agreed, I often use # comments in my shell pipelines and it constantly throws "Empty / bogus instruction is invalid".

RUN true \
# blabla this
  && do_this \
# blabla that
  && do_that

aslafy-z avatar Oct 08 '18 18:10 aslafy-z