Last change
on this file was 3231, checked in by bird, 18 years ago |
eol style.
|
-
Property svn:eol-style
set to
native
|
File size:
902 bytes
|
Line | |
---|
1 | /* logname - print login name of current user */
|
---|
2 |
|
---|
3 | #include <config.h>
|
---|
4 |
|
---|
5 | #if defined (HAVE_UNISTD_H)
|
---|
6 | # include <unistd.h>
|
---|
7 | #endif
|
---|
8 |
|
---|
9 | #include <stdio.h>
|
---|
10 | #include <errno.h>
|
---|
11 |
|
---|
12 | #include "builtins.h"
|
---|
13 | #include "shell.h"
|
---|
14 |
|
---|
15 | #if !defined (errno)
|
---|
16 | extern int errno;
|
---|
17 | #endif
|
---|
18 |
|
---|
19 | logname_builtin (list)
|
---|
20 | WORD_LIST *list;
|
---|
21 | {
|
---|
22 | char *np;
|
---|
23 |
|
---|
24 | if (no_options (list))
|
---|
25 | return (EX_USAGE);
|
---|
26 |
|
---|
27 | np = getlogin ();
|
---|
28 | if (np == 0)
|
---|
29 | {
|
---|
30 | builtin_error ("cannot find username: %s", strerror (errno));
|
---|
31 | return (EXECUTION_FAILURE);
|
---|
32 | }
|
---|
33 | printf ("%s\n", np);
|
---|
34 | return (EXECUTION_SUCCESS);
|
---|
35 | }
|
---|
36 |
|
---|
37 | char *logname_doc[] = {
|
---|
38 | "write the current user's login name to the standard output",
|
---|
39 | "and exit. logname ignores the LOGNAME and USER variables.",
|
---|
40 | "logname ignores any non-option arguments.",
|
---|
41 | (char *)NULL
|
---|
42 | };
|
---|
43 |
|
---|
44 | struct builtin logname_struct = {
|
---|
45 | "logname",
|
---|
46 | logname_builtin,
|
---|
47 | BUILTIN_ENABLED,
|
---|
48 | logname_doc,
|
---|
49 | "logname",
|
---|
50 | 0
|
---|
51 | };
|
---|
52 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.