MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / internalMacUserShell

Function internalMacUserShell

pkg/util/shellutil/shellutil.go:119–137  ·  view source on GitHub ↗

dscl . -read /Users/[username] UserShell defaults to /bin/bash

()

Source from the content-addressed store, hash-verified

117// dscl . -read /Users/[username] UserShell
118// defaults to /bin/bash
119func internalMacUserShell() string {
120 osUser, err := user.Current()
121 if err != nil {
122 return DefaultShellPath
123 }
124 ctx, cancelFn := context.WithTimeout(context.Background(), 2*time.Second)
125 defer cancelFn()
126 userStr := "/Users/" + osUser.Username
127 out, err := exec.CommandContext(ctx, "dscl", ".", "-read", userStr, "UserShell").CombinedOutput()
128 if err != nil {
129 return DefaultShellPath
130 }
131 outStr := strings.TrimSpace(string(out))
132 m := userShellRegexp.FindStringSubmatch(outStr)
133 if m == nil {
134 return DefaultShellPath
135 }
136 return m[1]
137}
138
139func hasDirPart(dir string, part string) bool {
140 dir = filepath.Clean(dir)

Callers 1

GetMacUserShellFunction · 0.85

Calls 1

CombinedOutputMethod · 0.80

Tested by

no test coverage detected