mirror of
https://github.com/wahyd4/jabba.git
synced 2026-08-09 04:46:17 +10:00
25 lines
632 B
Go
25 lines
632 B
Go
package command
|
|
|
|
import (
|
|
"github.com/shyiko/jabba/cfg"
|
|
"os"
|
|
"path/filepath"
|
|
"regexp"
|
|
)
|
|
|
|
func Deactivate() ([]string, error) {
|
|
pth, _ := os.LookupEnv("PATH")
|
|
rgxp := regexp.MustCompile(regexp.QuoteMeta(filepath.Join(cfg.Dir(), "jdk")) + "[^:]+[:]")
|
|
// strip references to ~/.jabba/jdk/*, otherwise leave unchanged
|
|
pth = rgxp.ReplaceAllString(pth, "")
|
|
javaHome, overrideWasSet := os.LookupEnv("JAVA_HOME_BEFORE_JABBA")
|
|
if !overrideWasSet {
|
|
javaHome, _ = os.LookupEnv("JAVA_HOME")
|
|
}
|
|
return []string{
|
|
"export PATH=\"" + pth + "\"",
|
|
"export JAVA_HOME=\"" + javaHome + "\"",
|
|
"unset JAVA_HOME_BEFORE_JABBA",
|
|
}, nil
|
|
}
|