Skip to content
This repository has been archived by the owner on Nov 7, 2023. It is now read-only.

Commit

Permalink
Filter reattach-to-user-namespace warning on macOS kr restart
Browse files Browse the repository at this point in the history
  • Loading branch information
kcking committed Jun 19, 2018
1 parent cb213a7 commit fab4dc2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions kr/kr_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,21 @@ func runCommandTmuxFriendly(cmd string, args ...string) (output string, err erro
return
}

func filterReattachToUserNamespaceOutput(output string) string {
// reattach-to-user-namespace prints a warning on 10.14, filter this
// output so that a false positive is not created for launchctl load error
// detection
lines := strings.Split(output, "\n")
filteredLines := []string{}
for _, line := range lines {
if strings.Contains(line, "reattach-to-user-namespace") {
continue
}
filteredLines = append(filteredLines, line)
}
return strings.Join(filteredLines, "\n")
}

func startKrd() (err error) {
err = copyPlist()
if err != nil {
Expand All @@ -84,6 +99,8 @@ func startKrd() (err error) {
}
_, _ = runCommandTmuxFriendly("launchctl", "unload", homePlist)
output, err := runCommandTmuxFriendly("launchctl", "load", homePlist)
output = filterReattachToUserNamespaceOutput(output)
// launchctl load exit status only reflects syntax, not execution failure (always returns 0)
if len(output) > 0 || err != nil {
err = fmt.Errorf(kr.Red("Krypton ▶ Error starting krd with launchctl: " + string(output)))
PrintErr(os.Stderr, err.Error())
Expand Down

0 comments on commit fab4dc2

Please sign in to comment.