This repository has been archived by the owner on Feb 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 95
printExport support for fish-shell #295
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1a3d05e
printExport support for fish-shell (based on boot2docker/boot2docker-…
douglascamata 66eb471
printExport always showing the export/unset commands
douglascamata 7784a09
bash's behavior is default in printExport
douglascamata 8287ae8
refactoring printExport again
douglascamata 5e8d8c9
type fixed in printExport
douglascamata c7e7beb
getting rid of unnecessary variable attribution
douglascamata 8c9238e
forgot to add value in the fish variable export, sorry
douglascamata 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 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 |
---|---|---|
|
@@ -5,6 +5,7 @@ import ( | |
"fmt" | ||
"os" | ||
"os/exec" | ||
"path/filepath" | ||
"regexp" | ||
"runtime" | ||
"strings" | ||
|
@@ -193,12 +194,19 @@ func checkEnvironment(socket, certPath string) bool { | |
|
||
func printExport(socket, certPath string) { | ||
for name, value := range exports(socket, certPath) { | ||
if os.Getenv(name) != value { | ||
switch filepath.Base(os.Getenv("SHELL")) { | ||
case "fish": | ||
if value == "" { | ||
fmt.Printf(" unset %s\n", name) | ||
fmt.Printf(" set -e %s\n", name) | ||
} else { | ||
fmt.Printf(" export %s=%s\n", name, value) | ||
fmt.Printf(" set -x %s %s\n", name, value) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't there still be an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (don't know Fish scripting at all :D) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tianon no, sir. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool, thanks for clarifying. 👍 |
||
} | ||
default: // default command to export variables POSIX shells, like bash, zsh, etc. | ||
if value == "" { | ||
fmt.Printf(" unset %s\n", name) | ||
} else { | ||
fmt.Printf(" export %s=%s\n", name, value) | ||
} | ||
} | ||
} | ||
} | ||
|
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.
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.
One thing we seem to have lost here is the automatic silencing.
In other words, if a variable is already set correctly, no message was output.
Do we want to preserve that functionality?
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.
Yeah, this was removed on purpose. 😄
See the discussion at boot2docker/boot2docker#585, especially:
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.
Ah, sorry I missed that. OK, great.
LGTM