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

WIP: Commands to get and set environment variables #265

Closed
wants to merge 2 commits into from

Conversation

mtijanic
Copy link
Member

Incremental update to the commands per #6 , allows querying and setting local variables. To be used with hot reload commands that are WIP.

{
std::string varname = s.substr(0, equals);
std::string value = s.substr(equals+1, std::string::npos);
if (setenv(varname.c_str(), value.c_str(), 1) == 0)
Copy link
Member

Choose a reason for hiding this comment

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

I think this is problematic. setenv is not thread safe. I think a safer design would be to extend the Config service so that you can change config settings that way.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thread safety is not an issue since this all runs on the main thread. But you make a valid point that they are better suited for the Config service. I'm thinking map<string varname, string override_value> that you can set through the command line, and some way for plugins to register a callback when a config option changes.
The big advantage there would be that changes would not persist across NWNX reboots.
Adding a WIP tag here.

@mtijanic mtijanic changed the title Commands to get and set environment variables WIP: Commands to get and set environment variables Dec 23, 2018
@mtijanic
Copy link
Member Author

(Closing this for not as all of the code is gonna be thrown away anyway)

@mtijanic mtijanic closed this Jan 12, 2019
@mtijanic mtijanic deleted the commands-part2 branch January 12, 2019 22:59
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

2 participants