-
Notifications
You must be signed in to change notification settings - Fork 7
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 %, %%, #, ## operators #6
Conversation
export FOO="bar" echo '${FOO:-buzz}' | go run ./cmd/interpolate/main.go
This will make it easier to expand and support other operators
c0751d4
to
d65473d
Compare
d65473d
to
be6373b
Compare
|
||
go 1.12 | ||
|
||
require github.com/drone/envsubst v1.0.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to require this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, its used by substitutions.go
The official Go behaves a bit differently, here is the diff:
diff --git i/this.go w/this.go
index d39d244..9306b0c 100644
--- i/this.go
+++ w/this.go
@@ -6,14 +6,13 @@ package path
import (
"errors"
- "strings"
"unicode/utf8"
)
-// ErrBadPattern indicates a pattern was malformed.
+// ErrBadPattern indicates a globbing pattern was malformed.
var ErrBadPattern = errors.New("syntax error in pattern")
-// Match reports whether name matches the shell pattern.
+// Match reports whether name matches the shell file name pattern.
// The pattern syntax is:
//
// pattern:
@@ -43,7 +42,10 @@ Pattern:
star, chunk, pattern = scanChunk(pattern)
if star && chunk == "" {
// Trailing * matches rest of string unless it has a /.
- return !strings.Contains(name, "/"), nil
+ // return !strings.Contains(name, "/"), nil
+
+ // Return rest of string
+ return true, nil
}
// Look for match at current position.
t, ok, err := matchChunk(chunk, name)
@@ -59,8 +61,7 @@ Pattern:
}
if star {
// Look for match skipping i+1 bytes.
- // Cannot skip /.
- for i := 0; i < len(name) && name[i] != '/'; i++ {
+ for i := 0; i < len(name); i++ {
t, ok, err := matchChunk(chunk, name[i+1:])
if ok {
// if we're the last chunk, make sure we exhausted the name
@@ -158,9 +159,6 @@ func matchChunk(chunk, s string) (rest string, ok bool, err error) {
}
case '?':
- if s[0] == '/' {
- return
- }
_, n := utf8.DecodeRuneInString(s)
s = s[n:]
chunk = chunk[1:]
Aside from the Just checking, are all these new expansions standard bash ones? |
They are, check: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02 and https://www.tldp.org/LDP/abs/html/parameter-substitution.html I was going to add |
I'm uncomfortable bringing in Besides that, if we were going to bring in that dependency, we should just move entirely to that library and contribute upstream. |
I understand, I would say that file is not the main thing tho, as its 3 lines modified on the file upstream, I would have to basically do the same and copy the file here. I thought it would be better to give them credit by referencing their project than re-implement it here. I think it would be a great idea to "merge" the projects and just contribute to that one, I suggested using
|
@lox what would be your preferred approach here? |
Any updates on this? |
Merged master to resolve conflicts. |
I'm not too fussed about merging this in here, the complexity is that we'd need to match the same rules in Buildkite's backend parser. @yob thoughts? |
Add support for more interpolations
Notes
Relates to #2