2 * Copyright (c) 1985 Regents of the University of California.
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
7 #pragma ident "%Z%%M% %I% %E% SMI"
16 #define SHELLS "/etc/shells"
19 * Do not add local shells here. They should be added in /etc/shells
21 static char *okshells
[] =
22 { "/bin/sh", "/bin/csh", "/usr/bin/sh", "/usr/bin/csh", 0 };
24 static char **shells
, *strings
;
25 static char **curshell
;
27 static char **initshells(void);
30 * Get a list of shells from SHELLS, if it exists.
38 curshell
= initshells();
62 curshell
= initshells();
78 if ((fp
= fopen(SHELLS
, "r")) == (FILE *)0)
80 if (fstat(fileno(fp
), &statb
) == -1) {
84 if ((strings
= malloc((unsigned)statb
.st_size
+ 1)) == NULL
) {
88 shells
= (char **)calloc((unsigned)statb
.st_size
/ 3, sizeof (char *));
97 while (fgets(cp
, MAXPATHLEN
+ 1, fp
) != NULL
) {
98 while (*cp
!= '#' && *cp
!= '/' && *cp
!= '\0')
100 if (*cp
== '#' || *cp
== '\0')
103 while (!isspace(*cp
) && *cp
!= '#' && *cp
!= '\0')