-
Notifications
You must be signed in to change notification settings - Fork 27
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 export functionality #185
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #185 +/- ##
==========================================
- Coverage 35.02% 34.54% -0.49%
==========================================
Files 11 12 +1
Lines 708 718 +10
==========================================
Hits 248 248
- Misses 418 428 +10
Partials 42 42
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #185 +/- ##
=======================================
Coverage 37.93% 37.93%
=======================================
Files 13 13
Lines 783 783
=======================================
Hits 297 297
Misses 442 442
Partials 44 44 Continue to review full report at Codecov.
|
@@ -77,5 +77,11 @@ var ( | |||
flKey, | |||
}, | |||
}, | |||
{ | |||
Name: "export", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a print
subcommand in the tool, which prints envs in various formats. This functionality should be a new print format instead of a new subcommand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please give the name "envlist" to the new printing format.
if err != nil { | ||
continue | ||
} | ||
fmt.Printf("export %s=\"%s\"\n", key, value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using a simple "
without escaping is not safe. An env key value can be something that contains a doublequote, for example a singla "
so in this case the tool would print KEY="""
which is invalid.
Using an eval function (such as
eval $(go run . export)
) it's now possible to export the saved environmental variables to the host shell.