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

libsys: Add functions to read the environment variables without passing envp #503

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

samu698
Copy link
Contributor

@samu698 samu698 commented Jan 25, 2023

The functions sys::env::get and sys::env::get_envp allow to read the environment vars directly from the environ extern and it will allow to remove all the envp arguments passed to functions.

@samu698
Copy link
Contributor Author

samu698 commented Jan 25, 2023

After this PR is merged I have the next PR in my fork at https://github.com/samu698/Bear/tree/remove-envp 😉

Copy link
Owner

@rizsotto rizsotto left a comment

Choose a reason for hiding this comment

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

Hey @samu698 , thanks for this PR.

I had trouble with static variables in the past, that I would like to avoid. Could you explain why think this is needed? Or just make the function to return by value?

}

const Vars& get()
{
Copy link
Owner

Choose a reason for hiding this comment

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

This method does not look good to me! 😄 Static variables are source of bugs in my books.

The static variables can be avoided by change the return type by value (instead of by reference). You can still can capture the return value as const auto & to avoid copying. We shall just rely on compiler return value optimization then declaring static variables.

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.

2 participants