Line | |
---|
1 | /* |
---|
2 | * Dynamically build the shell prompt |
---|
3 | * |
---|
4 | * The license and distribution terms for this file may be |
---|
5 | * found in the file LICENSE in this distribution or at |
---|
6 | * http://www.rtems.org/license/LICENSE. |
---|
7 | */ |
---|
8 | |
---|
9 | #ifdef HAVE_CONFIG_H |
---|
10 | #include "config.h" |
---|
11 | #endif |
---|
12 | |
---|
13 | #include <stdio.h> |
---|
14 | #include <time.h> |
---|
15 | |
---|
16 | #include <rtems.h> |
---|
17 | #include <rtems/error.h> |
---|
18 | #include <rtems/libio.h> |
---|
19 | #include <rtems/libio_.h> |
---|
20 | #include <rtems/shell.h> |
---|
21 | #include "internal.h" |
---|
22 | |
---|
23 | #include <string.h> |
---|
24 | #include <stdlib.h> |
---|
25 | #include <ctype.h> |
---|
26 | #include <sys/stat.h> |
---|
27 | #include <unistd.h> |
---|
28 | #include <errno.h> |
---|
29 | #include <pwd.h> |
---|
30 | |
---|
31 | void rtems_shell_get_prompt( |
---|
32 | rtems_shell_env_t *shell_env, |
---|
33 | char *prompt, |
---|
34 | size_t size |
---|
35 | ) |
---|
36 | { |
---|
37 | char buf[256]; |
---|
38 | char *cwd; |
---|
39 | |
---|
40 | /* XXX: show_prompt user adjustable */ |
---|
41 | cwd = getcwd(buf,sizeof(buf)); |
---|
42 | cwd = cwd != NULL ? cwd : "?"; |
---|
43 | snprintf(prompt, size - 1, "%s%s[%s] %c ", |
---|
44 | ((shell_env->taskname) ? shell_env->taskname : ""), |
---|
45 | ((shell_env->taskname) ? " " : ""), |
---|
46 | cwd, |
---|
47 | geteuid()?'$':'#'); |
---|
48 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.