Skip to content

Commit

Permalink
Fix unintentional regression of unit code
Browse files Browse the repository at this point in the history
  • Loading branch information
CryoByte33 committed Nov 29, 2023
1 parent c526df2 commit 43165b2
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions internal/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,25 +252,22 @@ func getUnitStatus(param string) (string, error) {

var output string
cmd, err := exec.Command("sudo", "cat", tweak.Location).Output()

if err != nil {
if err != nil {
CryoUtils.ErrorLog.Println("Unable to get status of", param, ":", err)
return "nil", err
}
// This is just to get the actual value in units which present as a list.
if !strings.Contains(string(cmd), "[") {
return strings.TrimSpace(string(cmd)), nil
}

var output string
slice := strings.Fields(string(cmd))
for x := range slice {
if strings.Contains(slice[x], "[") {
output = strings.ReplaceAll(slice[x], "[", "")
output = strings.ReplaceAll(output, "]", "")
if strings.Contains(string(cmd), "[") {
slice := strings.Fields(string(cmd))
for x := range slice {
if strings.Contains(slice[x], "[") {
output = strings.ReplaceAll(slice[x], "[", "")
output = strings.ReplaceAll(output, "]", "")
}
}
} else {
output = strings.TrimSpace(string(cmd))
}

return output, nil
}

Expand Down

0 comments on commit 43165b2

Please sign in to comment.