Skip to content
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

Trailing colons in env breaks things #929

Merged
merged 2 commits into from
Jan 16, 2024
Merged

Trailing colons in env breaks things #929

merged 2 commits into from
Jan 16, 2024

Conversation

mxcl
Copy link
Member

@mxcl mxcl commented Jan 16, 2024

@coveralls
Copy link

coveralls commented Jan 16, 2024

Pull Request Test Coverage Report for Build 7547730951

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.5%) to 97.402%

Totals Coverage Status
Change from base Build 7500981722: 0.5%
Covered Lines: 1433
Relevant Lines: 1463

💛 - Coveralls

@@ -24,6 +24,10 @@ export default async function(pkgenv: { installations: Installation[] }) {

for (const key in rv) {
rv[key] = rv[key].replaceAll(new RegExp(`\\$${key}\\b`, 'g'), `\${${key}}`)
// don’t end with a trailing `:` since that is sometimes interpreted as CWD and can break things
// instead of `foo:${PATH}` we end up with `foo${PATH:+:PATH}` which is not POSIX but works
// with all realy shells to avoid the trailing `:`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/realy/really/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol not even sure what I meant to say. “Really” doesn't make sense

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, actually, it's probably real.

// don’t end with a trailing `:` since that is sometimes interpreted as CWD and can break things
// instead of `foo:${PATH}` we end up with `foo${PATH:+:PATH}` which is not POSIX but works
// with all realy shells to avoid the trailing `:`
rv[key] = rv[key].replaceAll(new RegExp(`:\\$\{${key}}`, 'g'), `\${${key}:+:$${key}}`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is succinct, but isn't it probably safer to do:

  .replaceAll(/::/, ':')
  .replace(/^:/, '')
  .replace(/:$/, '')

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you’re right. This isn’t good enough.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't bother with some of these as we construct this env ourselves. The runtime env from the package.yml could in theory cause a preceding : I guess.

@mxcl mxcl merged commit d80fe05 into main Jan 16, 2024
5 checks passed
@mxcl mxcl deleted the env-no-trailing-colons branch January 16, 2024 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants