Skip to content
This repository has been archived by the owner on Dec 9, 2018. It is now read-only.

Almost finish the env module #141

Merged
merged 3 commits into from
Apr 23, 2017
Merged

Almost finish the env module #141

merged 3 commits into from
Apr 23, 2017

Conversation

tbu-
Copy link
Collaborator

@tbu- tbu- commented Apr 22, 2017

The only function missing is home_dir

@homunkulus
Copy link
Collaborator

☔ The latest upstream changes (presumably #110) made this pull request unmergeable. Please resolve the merge conflicts.

@tbu-
Copy link
Collaborator Author

tbu- commented Apr 23, 2017

@homunkulus try

@homunkulus
Copy link
Collaborator

⌛ Trying commit a2c6ab8 with merge 8034123...

japaric pushed a commit that referenced this pull request Apr 23, 2017
Almost finish the `env` module

The only function missing is `home_dir`
@tbu-
Copy link
Collaborator Author

tbu- commented Apr 23, 2017

Hm. Travis doesn't appear here, but this shows as passed on Travis's website.

@homunkulus
Copy link
Collaborator

☀️ Test successful - status-travis
State: approved= try=True

Copy link
Owner

@japaric japaric left a comment

Choose a reason for hiding this comment

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

Excellent work as usual @tbu- 👍

r=me with nits addressed.

@homunkulus delegate+

src/libc/mod.rs Outdated
pub value: Cow<'static, [u8]>,
}

#[allow(unused)]
Copy link
Owner

Choose a reason for hiding this comment

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

Hmm, why is the allow(unused) required? ENV_PTR is used in _init down below, no? (Same with AUXVAL)

if input.is_empty() {
return None;
}
let pos = memchr(b'=', &input[1..]).map(|p| p + 1);
Copy link
Owner

Choose a reason for hiding this comment

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

It wasn't obvious to me why input is sliced like this. Could you copy this comment from std?

        // Strategy (copied from glibc): Variable name and value are separated
        // by an ASCII equals sign '='. Since a variable name must not be
        // empty, allow variable names starting with an equals sign. Skip all
        // malformed lines.

I'm not sure if it's around already but if it is then all these 1.. slicing operations should point out to that comment.

use vec;

static ENV_LOCK: () = ();
// TODO(steed): Synchronize environment access once we have mutexes.
Copy link
Owner

Choose a reason for hiding this comment

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

Could you open an issue about this? Now that we have threads this one may go very wrong if two or more threads try to set_env the same variable :-/.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

&*ENV
}

pub unsafe fn environ() -> *const *const c_char {
Copy link
Owner

Choose a reason for hiding this comment

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

Hmm, does this function actually make it to the std public API? It any case, I think this should panic like libc::errno. We should probably document these differences from std since there now would be two of them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, it doesn't make it to the public API, this is the stub for spawning new commands right now.

Copy link
Owner

Choose a reason for hiding this comment

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

Hmm, does that means that spawned processes don't inherit their parent's environment? We should create an issue about that if that's the case.

@japaric
Copy link
Owner

japaric commented Apr 23, 2017

@homunkulus delegate+

(I think the review comment is not picked by Homu)

@homunkulus
Copy link
Collaborator

✌️ @tbu- can now approve this pull request

@tbu-
Copy link
Collaborator Author

tbu- commented Apr 23, 2017

Since environ is not part of the public API, and since it was stubbed before this pull request, (I just moved it to libc), I'm going to merge this. I hope this is OK.

Addressed the other comments.

@homunkulus r+

@homunkulus
Copy link
Collaborator

📌 Commit 3c2bd06 has been approved by tbu-

@homunkulus
Copy link
Collaborator

⌛ Testing commit 3c2bd06 with merge db8fb00...

japaric pushed a commit that referenced this pull request Apr 23, 2017
Almost finish the `env` module

The only function missing is `home_dir`
@homunkulus
Copy link
Collaborator

☀️ Test successful - status-travis
Approved by: tbu-
Pushing db8fb00 to master...

@homunkulus homunkulus merged commit 3c2bd06 into japaric:master Apr 23, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants