-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Support bash-style ARG substitution #2389
Comments
This is similar to #1772 I'm starting to be in favor of #1772 but the problem with this one is that the replacement syntax is not part of posix but bash specific. And if you look at bash definition https://www.gnu.org/software/bash/manual/bash.html#Shell-Parameter-Expansion then there are a million other rules and we definitely can not implement all of them. I guess it might still be fine to add only this pattern from bash and document it as such but we need to support all posix patterns first as well. Is there a golang library that provides shell-style pattern matching? Because the current wildcard matching with I don't see a big issue of accepting this and #1772 to labs channel at least. FYI @thaJeztah |
This lib seems to be able to handle bash replacements and expansion but there are some caveats. |
Generally, I'd prefer sticking to POSIX as well, but if there's good/valid use-cases, we could of course expand.
There's some pros and cons to using a generic library;
|
@thaJeztah Ah, I just found related package and shared it same as @crazy-max. ARG LLVM_VERSION
ENV LLVM_VERSION_MAJOR=${LLVM_VERSION%%.*} actually, I want $ LLVM_VERSION=12.0.1; echo ${LLVM_VERSION%%.*}
12 but I agreed your concern.
Actually, I was thinking of fix the shell parser in the buildkit itself ( However, I found that is not Bourne Shell feature, GNU Bash expansions. then, I stopped sending PR because it is not a POSIX standard.
As a result, My opinion is to support only the POSIX standard. Because writing a parser that is fully compatible with GNU Bash is too hard, it's not buildkit main feature, and i's overkill to put to in the buildkit. (Well, I'm not a buildkit maintainer, sorry for commented my opinion :P) |
I could possibly be interested in helping work on this 👀 It definitely looks like it would be around the same parts of code I've been looking at before. I think if we wanted POSIX support (see 2.6.2 of the spec) we'd probably want to support the following:
We might also want to steal the following from bash/zsh, which is what users might expect:
It would probably be relatively straightforward to implement most of these, just dropping them straight into the lexer with the others (probably some small amount of refactoring involved too). However, once implemented, they need maintaining, so that's probably a trade-off to make. I'm also a fan of having it directly built into buildkit, instead of using an external library.
If that sounds reasonable, I'm happy to implement a basic prototype of the POSIX support (and maybe the bash-specific ones as well, to see how they'd fit in), so we could judge from there. |
For the rest, I think the more complicated part is that For the posix ones LGTM to implement them. For the rest, I'm not sure if the |
Description
Right now, it is a bit crufty to deal with substitutions of args. Ex $TARGETARCH -> s/amd64/X64 or even s/arm64/ARM64. It seems we could be better served if a limited version of bash style env substitution was allowed.
The text was updated successfully, but these errors were encountered: