-
Notifications
You must be signed in to change notification settings - Fork 421
implement getenv and putenv in go #1086
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
e03b78e
implement getenv and putenv in go
withinboredom d46938d
fix typo
withinboredom 59ab1ef
apply formatting
withinboredom 969ceea
return a bool
withinboredom 098c795
prevent ENV= from crashing
withinboredom 660dc99
optimization
withinboredom 0c795b9
optimization
withinboredom e6031cd
split env workflows and use go_strings
withinboredom 7b4c8ab
clean up unused code
withinboredom 4ef55f9
update tests
withinboredom 41ff6b2
remove useless sprintf
withinboredom 929a2c0
see if this fixes the asan issues
withinboredom 71279ff
clean up comments
withinboredom 2518bbb
check that VAR= works correctly and use actual php to validate the be…
withinboredom 61e4e20
move all unpinning to the end of the request
withinboredom a3cec5b
handle the case where php is not installed
withinboredom 7d64751
fix copy-paste
withinboredom 67a547c
optimization
withinboredom 02e8545
use strings.cut
withinboredom d2bf2d9
fix lint
withinboredom f97a34b
override how env is filled
withinboredom 1e5abb2
reuse fullenv
withinboredom b68cf50
use corect function
withinboredom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| <?php | ||
|
|
||
| require_once __DIR__.'/_executor.php'; | ||
|
|
||
| return function() { | ||
| $var = 'MY_VAR_' . ($_GET['var'] ?? ''); | ||
| // Setting an environment variable | ||
| $result = putenv("$var=HelloWorld"); | ||
| if ($result) { | ||
| echo "Set MY_VAR successfully.\n"; | ||
| echo "MY_VAR = " . getenv($var) . "\n"; | ||
| } else { | ||
| echo "Failed to set MY_VAR.\n"; | ||
| } | ||
|
|
||
| // Unsetting the environment variable | ||
| $result = putenv($var); | ||
| if ($result) { | ||
| echo "Unset MY_VAR successfully.\n"; | ||
| $value = getenv($var); | ||
| if ($value === false) { | ||
| echo "MY_VAR is unset.\n"; | ||
| } else { | ||
| echo "MY_VAR = " . $value . "\n"; | ||
| } | ||
| } else { | ||
| echo "Failed to unset MY_VAR.\n"; | ||
| } | ||
|
|
||
| $result = putenv("$var="); | ||
| if ($result) { | ||
| echo "MY_VAR set to empty successfully.\n"; | ||
| $value = getenv($var); | ||
| if ($value === false) { | ||
| echo "MY_VAR is unset.\n"; | ||
| } else { | ||
| echo "MY_VAR = " . $value . "\n"; | ||
| } | ||
| } else { | ||
| echo "Failed to set MY_VAR.\n"; | ||
| } | ||
|
|
||
| // Attempt to unset a non-existing variable | ||
| $result = putenv('NON_EXISTING_VAR' . ($_GET['var'] ?? '')); | ||
| if ($result) { | ||
| echo "Unset NON_EXISTING_VAR successfully.\n"; | ||
| } else { | ||
| echo "Failed to unset NON_EXISTING_VAR.\n"; | ||
| } | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.