mirror of
git://git.musl-libc.org/musl
synced 2025-03-06 20:48:29 +01:00
getusershell: skip blank lines and comments
this interface does not have a lot of historical consensus on how it handles the contents of the /etc/shells file in regard to whitespace and comments, but the commonality between all checked is that they ignore lines that are blank or that begin with '#', so that is the behavior we adopt.
This commit is contained in:
parent
53ac44ff4c
commit
ab31e9d6a0
1 changed files with 4 additions and 2 deletions
|
@ -25,8 +25,10 @@ char *getusershell(void)
|
|||
ssize_t l;
|
||||
if (!f) setusershell();
|
||||
if (!f) return 0;
|
||||
l = getline(&line, &linesize, f);
|
||||
if (l <= 0) return 0;
|
||||
do {
|
||||
l = getline(&line, &linesize, f);
|
||||
if (l <= 0) return 0;
|
||||
} while (line[0] == '#' || line[0] == '\n');
|
||||
if (line[l-1]=='\n') line[l-1]=0;
|
||||
return line;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue