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

Add Process.environment as a [String:String] dictionary #2757

Closed
wants to merge 1 commit into from
Closed

Add Process.environment as a [String:String] dictionary #2757

wants to merge 1 commit into from

Conversation

dunkelstern
Copy link

What's in this pull request?

Implemented Process.environment that takes it's values from the third parameter to the C main function (environ). Process.environment is a dictionary [String:String] of all defined environment variables. It does not update when the process executes a setenv system call.

Resolved bug number: (SR-1636)

Probably related: SR-1396


Before merging this pull request to apple/swift repository:

  • Test pull request on Swift continuous integration.

Triggering Swift CI

The swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:

Smoke Testing

Platform Comment
All supported platforms @swift-ci Please smoke test
All supported platforms @swift-ci Please smoke test and merge
OS X platform @swift-ci Please smoke test OS X platform
Linux platform @swift-ci Please smoke test Linux platform

Validation Testing

Platform Comment
All supported platforms @swift-ci Please test
All supported platforms @swift-ci Please test and merge
OS X platform @swift-ci Please test OS X platform
OS X platform @swift-ci Please benchmark
Linux platform @swift-ci Please test Linux platform

Lint Testing

Language Comment
Python @swift-ci Please Python lint

Note: Only members of the Apple organization can trigger swift-ci.

@gribozavr
Copy link
Collaborator

Thank you for your contribution. Because this is an API change, it needs to be proposed through the Swift evolution process (https://github.com/apple/swift-evolution). I'm closing the pull request for now.

@gribozavr gribozavr closed this May 28, 2016
@jckarter
Copy link
Member

jckarter commented May 31, 2016

Rather than propagate the poke-things-in-main hack in the compiler, we could just access the environ global directly from the standard library implementation.

@dunkelstern
Copy link
Author

I don't think of it much a hack as it is just using the default way to get to that list but i can of course try to use environ but it seems it is not imported into swift so i would have to change some c++ code for that too.

@jckarter
Copy link
Member

jckarter commented Jun 2, 2016

The way we set up argc and argv is broken, since it won't work for a DLL or a mixed-language project whose main isn't written in Swift. All of these globals really ought to be initialized from global state; unfortunately that requires unportable interfaces for argc and argv, but environ is supported on both BSD and Linux AFAICT.

@rintaro
Copy link
Member

rintaro commented Jun 2, 2016

@dunkelstern
Copy link
Author

Ah now I understand, i'll rewrite the patch to use environ instead, but the way of importing that will be the same.

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.

None yet

4 participants