Added gitignore entries needed to ignore derived objects generated from full build...
[bash.git] / examples / loadables / whoami.c
blob6f8471ac31778fb1170cd8ace74b4de9e364474f
1 /*
2 * whoami - print out username of current user
3 */
5 /*
6 Copyright (C) 1999-2009 Free Software Foundation, Inc.
8 This file is part of GNU Bash.
9 Bash is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 Bash is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Bash. If not, see <http://www.gnu.org/licenses/>.
23 #include <config.h>
24 #include <stdio.h>
26 #include "builtins.h"
27 #include "shell.h"
28 #include "bashgetopt.h"
29 #include "common.h"
31 whoami_builtin (list)
32 WORD_LIST *list;
34 int opt;
36 reset_internal_getopt ();
37 while ((opt = internal_getopt (list, "")) != -1)
39 switch (opt)
41 default:
42 builtin_usage ();
43 return (EX_USAGE);
46 list = loptend;
47 if (list)
49 builtin_usage ();
50 return (EX_USAGE);
53 if (current_user.user_name == 0)
54 get_current_user_info ();
55 printf ("%s\n", current_user.user_name);
56 return (EXECUTION_SUCCESS);
59 char *whoami_doc[] = {
60 "Print user name",
61 "",
62 "Display name of current user.",
63 (char *)NULL
66 struct builtin whoami_struct = {
67 "whoami",
68 whoami_builtin,
69 BUILTIN_ENABLED,
70 whoami_doc,
71 "whoami",