From 5f3600382421943f93dfd698439bea9bdeccf07e Mon Sep 17 00:00:00 2001 From: Chris McGee Date: Sun, 26 Jan 2025 19:59:23 -0500 Subject: [PATCH] Check the correct prefix for the current user on Linux when finding their shell --- Sources/LinuxPlatform/Linux.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/LinuxPlatform/Linux.swift b/Sources/LinuxPlatform/Linux.swift index 824786f2..c897a197 100644 --- a/Sources/LinuxPlatform/Linux.swift +++ b/Sources/LinuxPlatform/Linux.swift @@ -543,9 +543,11 @@ public struct Linux: Platform { } public func getShell() async throws -> String { + let userName = ProcessInfo.processInfo.userName + let prefix = "\(userName):" if let passwds = try await runProgramOutput("getent", "passwd") { for line in passwds.components(separatedBy: "\n") { - if line.hasPrefix("root:") { + if line.hasPrefix(prefix) { if case let comps = line.components(separatedBy: ":"), comps.count > 1 { return comps[comps.count - 1] }