-
-
Notifications
You must be signed in to change notification settings - Fork 227
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
env var replacement not supporting ${VAR_NAME}
syntax
#1392
Conversation
- simplified and cleaner env var replacement using straighforward regex replaceAll - support ${MY_VAR}suffix replacements
Thanks for your pull request, @MartinNowak! |
Did you check if we get any significant compile-time regressions due to Otherwise LGTM. BTW, I'll go through the commit history to add missing change log entries once more, but I already wanted to suggest that we switch to a mode where each significant PR must add a change log entry, because I simply didn't manage to manually author them in time recently. We should probably add a CONTRIBUTING file at some point mentioning this. |
Yeah, replaced it with a runtime regex (btw, nowadays even |
Didn't know that. Then we can also remove the manual caching that is done in other places within DUB. |
Of course it's messier than explainable, seems like BTW, I think it would be a net positive for dub to get rid of NativePath. Slash behavior originally introduced here vibe-d/vibe.d@970a022#diff-3620332feace439ec637b023bc2e7a01R262, and apparently broken here vibe-d/vibe.d@344fe34#diff-47d6be40e29a186df00d5f3bfad92671R36. |
Depends on expectations, https://github.com/dlang/phobos/blob/b26aad3209c1adb3006ff7003c44a7f0cdde06d9/std/regex/package.d#L364, 8 entries isn't necessarily enough, but processVars calls are coming all at once. |
Does that look reasonable? It seems that the chances for breakage are small as |
a8f5adb
to
73ec880
Compare
If you add a changelog entry to I recently added support for this on tools/dlang.org side for this: Integrating the GitHub issues (like @dlang-bot currently does) is more work and I wasn't sure whether that's wanted, so I left that one out for now. |
With dlang/phobos#6268 (in the upcoming 2.080) std.regex caching got a big improvement. |
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.
Does that look reasonable? It seems that the chances for breakage are small as $PATHsuffix wasn't possible beforehand, so mostly cd $PATH && ./script were used.
Could subtly break weird path based comparisons or concatenations in scripts though.
It doesn't break anything in the ~40 projects on Jenkins, so that's a good start.
And yes not using a trailing looks and thus having a unified behavior for the path variables looks very reasonable to me.
source/dub/project.d
Outdated
enum isPath = true; | ||
|
||
version (Posix) enum sep = "/"; | ||
else version (Windows) enum sep = `\`; |
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.
aka as std.path.dirSeparator
source/dub/project.d
Outdated
if (name == "PACKAGE_DIR") | ||
path = pack.path; | ||
else if (name == "ROOT_PACKAGE_DIR") | ||
path = project.rootPackage.path; | ||
|
||
if (name.endsWith("_PACKAGE_DIR")) { | ||
auto pname = name[0 .. $-12]; | ||
foreach (prj; project.getTopologicalPackageList()) | ||
if (prj.name.toUpper().replace("-", "_") == pname) |
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.
FWIW there's no need to allocate for this check,sth. like this should work fine and is @nogc:
prj.name.asUpperCase.map!(a == '-' ? '_' : a).equal(pname)
- simplified and cleaner env var replacement using straighforward regex replaceAll - support ${MY_VAR}suffix replacements
Addressed my review myself and rebased (the changelog entry is now in |
- simplified and cleaner env var replacement using straighforward regex replaceAll - support ${MY_VAR}suffix replacements
Rebased again :/ |
- simplified and cleaner env var replacement using straighforward regex replaceAll - support ${MY_VAR}suffix replacements
- cached by std.regex
- expand $VARS without trailing slash/backslash (for concatenation e.g. `${PACKAGE_PATH}/subpath`)
This was broken by the refactoring in dlang#1392 (commit 14c00c4)
This was broken by the refactoring in dlang#1392 (commit 14c00c4)
This was broken by the refactoring in dlang#1392 (commit 14c00c4)
This was broken by the refactoring in dlang#1392 (commit 14c00c4)
This is commonly needed to join pathes or a suffix, e.g.
$PACKAGE_DIRmylib.a
(as unfortunately PACKAGE_DIR ends on/
).Expanding variables is straighforward, https://github.com/MartinNowak/alertd/blob/cbc4459bbdbcc8c799413f58a591f6d28205f147/src/alertd.d#L503.