mirror of
https://github.com/apple/container.git
synced 2026-10-14 01:59:18 +00:00
Skip comment lines when parsing the passwd and group files (#728)
Skips comment lines when parsing the `passwd` and `group` files.
This commit is contained in:
1 parent
03280f3952
commit
e9f4ece2bb
1 file changed
+6
-2
@@ -115,10 +115,14 @@ extension User {
|
||||
let content = try String(contentsOf: file, encoding: .ascii)
|
||||
let lines = content.components(separatedBy: .newlines)
|
||||
for line in lines {
|
||||
guard !line.isEmpty else {
|
||||
let trimmed = line.trimmingCharacters(in: .whitespaces)
|
||||
guard !trimmed.isEmpty else {
|
||||
continue
|
||||
}
|
||||
try handler(line.trimmingCharacters(in: .whitespaces))
|
||||
guard !trimmed.hasPrefix("#") else {
|
||||
continue
|
||||
}
|
||||
try handler(trimmed)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user