Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:19

0001 /*
0002  *  Dynamically build the shell prompt
0003  *
0004  *  The license and distribution terms for this file may be
0005  *  found in the file LICENSE in this distribution or at
0006  *  http://www.rtems.org/license/LICENSE.
0007  */
0008 
0009 #ifdef HAVE_CONFIG_H
0010 #include "config.h"
0011 #endif
0012 
0013 #include <stdio.h>
0014 #include <time.h>
0015 
0016 #include <rtems.h>
0017 #include <rtems/error.h>
0018 #include <rtems/libio.h>
0019 #include <rtems/libio_.h>
0020 #include <rtems/shell.h>
0021 #include "internal.h"
0022 
0023 #include <string.h>
0024 #include <stdlib.h>
0025 #include <ctype.h>
0026 #include <sys/stat.h>
0027 #include <unistd.h>
0028 #include <errno.h>
0029 #include <pwd.h>
0030 
0031 void rtems_shell_get_prompt(
0032   rtems_shell_env_t *shell_env,
0033   char              *prompt,
0034   size_t             size
0035 )
0036 {
0037   char buf[256];
0038   char *cwd;
0039 
0040   /* XXX: show_prompt user adjustable */
0041   cwd = getcwd(buf,sizeof(buf));
0042   cwd = cwd != NULL ? cwd : "?";
0043   snprintf(prompt, size - 1, "%s%s[%s] %c ",
0044           ((shell_env->taskname) ? shell_env->taskname : ""),
0045           ((shell_env->taskname) ? " " : ""),
0046           cwd,
0047           geteuid()?'$':'#');
0048 }