Expunge revision histories.
[shells] / ushell.c
CommitLineData
ed36b0a2 1/* -*-c-*-
2 *
4a9966ef 3 * $Id$
ed36b0a2 4 *
5 * Extract a user's shell
6 *
7 * (c) 1999 Mark Wooding
8 */
9
10/*----- Licensing notice --------------------------------------------------*
11 *
ffe3ac31 12 * This program is free software; you can redistribute it and/or modify
ed36b0a2 13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
ffe3ac31 17 * This program is distributed in the hope that it will be useful,
ed36b0a2 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
ffe3ac31 23 * along with this program; if not, write to the Free Software Foundation,
ed36b0a2 24 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 */
26
ed36b0a2 27/*----- Header files ------------------------------------------------------*/
28
29#include <errno.h>
30#include <stdio.h>
31#include <stdlib.h>
32#include <string.h>
33#include <pwd.h>
34#include <sys/types.h>
35#include <unistd.h>
36
37/*----- Main code ---------------------------------------------------------*/
38
39static const char *quis;
40
41int main(int argc, char *argv[])
42{
43 struct passwd *pw;
44
45 /* --- Resolve the program name --- */
46
47 {
48 char *p, *q;
49 p = argv[0];
50 for (q = argv[0]; *q; q++) {
51 if (*q == '/')
52 p = q + 1;
53 }
54 quis = p;
55 }
56
57 /* --- Get the argument name --- */
58
59 if (argc != 2) {
60 fprintf(stderr, "Usage: %s username\n", quis);
61 exit(EXIT_FAILURE);
62 }
63
64 /* --- Read the user information --- */
65
66 if ((pw = getpwnam(argv[1])) == 0) {
67 fprintf(stderr, "%s: user `%s' doesn't exist", quis, argv[1]);
68 exit(EXIT_FAILURE);
69 }
70
71 /* --- Done --- */
72
73 puts(pw->pw_shell);
74 return (0);
75}
76
77/*----- That's all, folks -------------------------------------------------*/