|
Last change
on this file since 3280 was 3231, checked in by bird, 19 years ago |
|
eol style.
|
-
Property svn:eol-style
set to
native
|
|
File size:
804 bytes
|
| Line | |
|---|
| 1 | /*
|
|---|
| 2 | * whoami - print out username of current user
|
|---|
| 3 | */
|
|---|
| 4 |
|
|---|
| 5 | #include <config.h>
|
|---|
| 6 | #include <stdio.h>
|
|---|
| 7 |
|
|---|
| 8 | #include "builtins.h"
|
|---|
| 9 | #include "shell.h"
|
|---|
| 10 | #include "bashgetopt.h"
|
|---|
| 11 |
|
|---|
| 12 | whoami_builtin (list)
|
|---|
| 13 | WORD_LIST *list;
|
|---|
| 14 | {
|
|---|
| 15 | int opt;
|
|---|
| 16 |
|
|---|
| 17 | reset_internal_getopt ();
|
|---|
| 18 | while ((opt = internal_getopt (list, "")) != -1)
|
|---|
| 19 | {
|
|---|
| 20 | switch (opt)
|
|---|
| 21 | {
|
|---|
| 22 | default:
|
|---|
| 23 | builtin_usage ();
|
|---|
| 24 | return (EX_USAGE);
|
|---|
| 25 | }
|
|---|
| 26 | }
|
|---|
| 27 | list = loptend;
|
|---|
| 28 | if (list)
|
|---|
| 29 | {
|
|---|
| 30 | builtin_usage ();
|
|---|
| 31 | return (EX_USAGE);
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | if (current_user.user_name == 0)
|
|---|
| 35 | get_current_user_info ();
|
|---|
| 36 | printf ("%s\n", current_user.user_name);
|
|---|
| 37 | return (EXECUTION_SUCCESS);
|
|---|
| 38 | }
|
|---|
| 39 |
|
|---|
| 40 | char *whoami_doc[] = {
|
|---|
| 41 | "display name of current user",
|
|---|
| 42 | (char *)NULL
|
|---|
| 43 | };
|
|---|
| 44 |
|
|---|
| 45 | struct builtin whoami_struct = {
|
|---|
| 46 | "whoami",
|
|---|
| 47 | whoami_builtin,
|
|---|
| 48 | BUILTIN_ENABLED,
|
|---|
| 49 | whoami_doc,
|
|---|
| 50 | "whoami",
|
|---|
| 51 | 0
|
|---|
| 52 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.