Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion segment-goenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func checkForGoenvOutput() (string, error) {
// spawn goenv and print out version
out, err := runGoenvCommand("goenv", "version")
if err == nil {
items := strings.Split(out, " ")
items := strings.SplitN(out, " ", 2)
if len(items) > 1 {
return items[0], nil
}
Expand Down
2 changes: 1 addition & 1 deletion segment-kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func segmentKube(p *powerline) []pwl.Segment {
// So we ensure there are three segments split by / and then choose the middle part,
// we also remove the port number from the result.
if p.cfg.ShortenOpenshiftNames {
segments := strings.Split(cluster, "/")
segments := strings.SplitN(cluster, "/", 4)
if len(segments) == 3 {
cluster = segments[1]
idx := strings.IndexByte(cluster, ':')
Expand Down
4 changes: 2 additions & 2 deletions segment-rbenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ func checkForRbenvOutput() (string, error) {
if err != nil {
return "", errors.New("Not found in rbenv output")
}
items := strings.Split(out, " ")
if len(items) <= 0 {
items := strings.SplitN(out, " ", 2)
if len(items) == 0 {
return "", errors.New("Not found in rbenv output")
}

Expand Down
11 changes: 5 additions & 6 deletions segment-rvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func checkEnvForRubyVersion() (string, error) {

// check GEM_HOME variable for gemset information
func checkEnvForRubyGemset() (string, error) {
gemHomeSegments := strings.Split(os.Getenv("GEM_HOME"), "@")
gemHomeSegments := strings.SplitN(os.Getenv("GEM_HOME"), "@", 3)

if len(gemHomeSegments) <= 1 {
return "", errors.New("Gemset not found in GEM_HOME")
Expand All @@ -42,8 +42,8 @@ func checkForRvmOutput() (string, error) {
if err != nil {
return "", errors.New("Not found in RVM output")
}
items := strings.Split(out, " ")
if len(items) <= 0 {
items := strings.SplitN(out, " ", 2)
if len(items) == 0 {
return "", errors.New("Not found in RVM output")
}

Expand All @@ -68,14 +68,13 @@ func segmentRvm(p *powerline) []pwl.Segment {
}

// Remove explicit "ruby-" prefix from segment because it's superfluous
segment_components := strings.Split(segment, "-")
segment_components := strings.SplitN(segment, "-", 3)
if len(segment_components) > 1 {
segment = segment_components[1]
}

// If gemset is missing from segment, get that info from the environment
segment_components = strings.Split(segment, "@")
if len(segment_components) < 2 {
if !strings.Contains(segment, "@") {
gemset, err := checkEnvForRubyGemset()
if err == nil && gemset != "" {
segment = segment + "@" + gemset
Expand Down
2 changes: 1 addition & 1 deletion segment-subversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func parseSvnURL() (map[string]string, error) {
infos := strings.Split(info, "\n")
if len(infos) > 1 {
for _, line := range infos[:] {
items := strings.Split(line, ": ")
items := strings.SplitN(line, ": ", 3)
if len(items) >= 2 {
svnInfo[items[0]] = items[1]
}
Expand Down