Skip to content
This repository has been archived by the owner on Feb 27, 2018. It is now read-only.

printExport support for fish-shell #295

Merged
merged 7 commits into from
Oct 23, 2014
Merged

Conversation

douglascamata
Copy link
Contributor

This is, basically, just an upstream update of #260. I just didn't used @kevinbin commits 'cause I couldn't find his repo anymore to merge with my remote.

@tianon tianon mentioned this pull request Oct 22, 2014
@tianon
Copy link
Contributor

tianon commented Oct 22, 2014

I think the discussion on boot2docker/boot2docker#585 is relevant here. I'm very much +1 on the feature, but I think it could be cleaner if we could get rid of that outer if entirely, and perhaps turn the SHELL if block into a switch so we leave room for new shell syntaxes to be added easily. What do you think?

@douglascamata
Copy link
Contributor Author

@tianon awesome! I'll update the pull request soon with the refactoring. Thanks!

@unbalancedparentheses
Copy link

Awesome. This would be really useful for fish shell users :). 👍

@tianon
Copy link
Contributor

tianon commented Oct 23, 2014

@douglascamata I'm prepping to do a 1.3.1 and I'd really like to see this in it 😄

Do you mind if I just steal your commit and take over from here? How much of the refactor did you get a chance to get into?

@douglascamata
Copy link
Contributor Author

@tianon I forgot to do it (sorry), gimme just a few minutes.

@tianon
Copy link
Contributor

tianon commented Oct 23, 2014

@douglascamata sure! 😄

@douglascamata
Copy link
Contributor Author

@tianon I'll use bash syntax as default in theswitch, do you agree?

@tianon
Copy link
Contributor

tianon commented Oct 23, 2014

Absolutely, that sounds reasonable to me.

@tianon
Copy link
Contributor

tianon commented Oct 23, 2014

(maybe even just a comment out to the side of default: like default: // bash, etc. to make it clear that's the assumption)

@tianon tianon added this to the 1.3.1 milestone Oct 23, 2014
@tianon
Copy link
Contributor

tianon commented Oct 23, 2014

Would you mind duplicating the outer if instead of the switch? I think it'll help to keep the "same shell" syntax together to make sure we don't miss more lines as/if this list grows.

@tianon
Copy link
Contributor

tianon commented Oct 23, 2014

(ie, switch shell { case "fish": if value == "" { ... } else {... } ...)

@douglascamata
Copy link
Contributor Author

@tianon okay 👍

@douglascamata
Copy link
Contributor Author

@tianon sorry for the broken builds, hahahaha.

@tianon
Copy link
Contributor

tianon commented Oct 23, 2014

No worries! LGTM

@gmlewis @Moghedrin care to review this one too? 😄

@tianon
Copy link
Contributor

tianon commented Oct 23, 2014

(and thanks so much for the quick turnaround on this @douglascamata 😄)

@douglascamata
Copy link
Contributor Author

@tianon it's a pleasure to contribute, even more if it's with something you use daily and the maintainers are active and cool 👍

} else {
fmt.Printf(" export %s=%s\n", name, value)
fmt.Printf(" set -x %s\n", name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't you want to use the value here somehow?

Copy link
Contributor

Choose a reason for hiding this comment

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

Otherwise, LGTM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gmlewis can't believe I let this... fixed!

Copy link
Contributor

Choose a reason for hiding this comment

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

hahahaha, how embarrassing on my part for missing that - this is why we like to double up on reviews ❤️

} else {
fmt.Printf(" export %s=%s\n", name, value)
fmt.Printf(" set -x %s %s\n", name, value)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't there still be an = here? (ie, set -x %s=%s)

Copy link
Contributor

Choose a reason for hiding this comment

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

(don't know Fish scripting at all :D)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tianon no, sir. Fish syntax for set is like: set -x DOCKER_HOST tcp://192.168.59.103:2376

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool, thanks for clarifying. 👍

@tianon
Copy link
Contributor

tianon commented Oct 23, 2014

re-LGTM

@tianon
Copy link
Contributor

tianon commented Oct 23, 2014

@gmlewis wanna give it another once-over? 👼

@@ -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 {
Copy link
Contributor

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?

Copy link
Contributor

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's no harm in exporting the same value again :)

(although the explicit "unset"s are nice, so keeping those and expanding
them to include all possible vars as either an "export XYZ=..." or an
explicit "unset XYZ" would be superb)

Copy link
Contributor

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

@tianon
Copy link
Contributor

tianon commented Oct 23, 2014

Thanks @gmlewis ❤️

(and no worries - can't expect you to watch everything everywhere 😄)

tianon added a commit that referenced this pull request Oct 23, 2014
printExport support for fish-shell
@tianon tianon merged commit 8ce6c3a into boot2docker:master Oct 23, 2014
@gmlewis
Copy link
Contributor

gmlewis commented Oct 23, 2014

Thanks, @tianon ! Yeah, you've probably noticed that I follow the code more than I follow the conversations. :-)

@tianon
Copy link
Contributor

tianon commented Oct 23, 2014

Yeah, and that's perfect - we appreciate your presence very much! :D

SvenDowideit pushed a commit to SvenDowideit/boot2docker-cli that referenced this pull request Nov 10, 2014
@rstacruz
Copy link

so how do i eval it in fish?

@miki725
Copy link

miki725 commented Jul 3, 2015

I use this command for now:

boot2docker shellinit | sed s/"="/" "/ | awk '{print "set -gx " $2 " \"" $3 "\""}' | source

also you can make a function to do that automatically:

function boot2docker_shellinit
    boot2docker shellinit | sed s/"="/" "/ | awk '{print "set -gx " $2 " \"" $3 "\""}' | source;
end

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants