Skip to content

Commit 51496e5

Browse files
authored
Check prefix for the current user on Linux when finding the shell (#206)
Check the correct prefix for the current user on Linux when finding their shell
1 parent 8fb4bef commit 51496e5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Sources/LinuxPlatform/Linux.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,9 +543,11 @@ public struct Linux: Platform {
543543
}
544544

545545
public func getShell() async throws -> String {
546+
let userName = ProcessInfo.processInfo.userName
547+
let prefix = "\(userName):"
546548
if let passwds = try await runProgramOutput("getent", "passwd") {
547549
for line in passwds.components(separatedBy: "\n") {
548-
if line.hasPrefix("root:") {
550+
if line.hasPrefix(prefix) {
549551
if case let comps = line.components(separatedBy: ":"), comps.count > 1 {
550552
return comps[comps.count - 1]
551553
}

0 commit comments

Comments
 (0)