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

Commit

Permalink
Merge pull request #295 from douglascamata/master
Browse files Browse the repository at this point in the history
printExport support for fish-shell
  • Loading branch information
tianon committed Oct 23, 2014
2 parents 29ee707 + 8c9238e commit 8ce6c3a
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions cmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"os/exec"
"path/filepath"
"regexp"
"runtime"
"strings"
Expand Down Expand Up @@ -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)
}
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)
}
}
}
}
Expand Down

0 comments on commit 8ce6c3a

Please sign in to comment.