diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2008-08-27 12:48:41 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2008-08-27 12:48:41 +0000 |
commit | f3db4ac83a4fa6b82d1671eb348ba3e4084dfde6 (patch) | |
tree | 359f38f8d01fa4d9c630e1fec28b236d2c543ed9 /cpukit/libmisc/shell/shell_getprompt.c | |
parent | 2008-08-27 Ralf Corsépius <ralf.corsepius@rtems.org> (diff) | |
download | rtems-f3db4ac83a4fa6b82d1671eb348ba3e4084dfde6.tar.bz2 |
2008-08-27 Joel Sherrill <joel.sherrill@OARcorp.com>
* libmisc/Makefile.am, libmisc/shell/shell.c, libmisc/shell/shell.h:
Split out rtems_shell_get_prompt() so it can be overridden by the
user.
* libmisc/shell/shell_getprompt.c: New file.
Diffstat (limited to 'cpukit/libmisc/shell/shell_getprompt.c')
-rw-r--r-- | cpukit/libmisc/shell/shell_getprompt.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/cpukit/libmisc/shell/shell_getprompt.c b/cpukit/libmisc/shell/shell_getprompt.c new file mode 100644 index 0000000000..5a445a0168 --- /dev/null +++ b/cpukit/libmisc/shell/shell_getprompt.c @@ -0,0 +1,49 @@ +/* + * Dynamically build the shell prompt + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <stdio.h> +#include <time.h> + +#include <rtems.h> +#include <rtems/error.h> +#include <rtems/libio.h> +#include <rtems/libio_.h> +#include <rtems/system.h> +#include <rtems/shell.h> +#include "internal.h" + +#include <string.h> +#include <stdlib.h> +#include <ctype.h> +#include <sys/stat.h> +#include <unistd.h> +#include <errno.h> +#include <pwd.h> + +void rtems_shell_get_prompt( + rtems_shell_env_t *shell_env, + char *prompt, + size_t size +) +{ + char curdir[256]; + + /* XXX: show_prompt user adjustable */ + getcwd(curdir,sizeof(curdir)); + snprintf(prompt, size - 1, "%s%s[%s] %c ", + ((shell_env->taskname) ? shell_env->taskname : ""), + ((shell_env->taskname) ? " " : ""), + curdir, + geteuid()?'$':'#'); +} |