Changeset 0c4f46a in mainline for uspace/app/bdsh/scli.c


Ignore:
Timestamp:
2008-08-30T15:05:54Z (16 years ago)
Author:
Tim Post <echo@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
42a0607
Parents:
43e02a6
Message:

Let 'cd' invoke cli_set_prompt(), no need to do it in every iteration of the main loop.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/scli.c

    r43e02a6 r0c4f46a  
    5757static void cli_finit(cliuser_t *usr);
    5858
    59 /* (re)allocates memory to store the current working directory, gets
    60  * and updates the current working directory, formats the prompt
    61  * string */
    62 unsigned int cli_set_prompt(cliuser_t *usr)
    63 {
    64         usr->prompt = (char *) realloc(usr->prompt, PATH_MAX);
    65         if (NULL == usr->prompt) {
    66                 cli_error(CL_ENOMEM, "Can not allocate prompt");
    67                 return 1;
    68         }
    69         memset(usr->prompt, 0, sizeof(usr->prompt));
    70 
    71         usr->cwd = (char *) realloc(usr->cwd, PATH_MAX);
    72         if (NULL == usr->cwd) {
    73                 cli_error(CL_ENOMEM, "Can not allocate cwd");
    74                 return 1;
    75         }
    76         memset(usr->cwd, 0, sizeof(usr->cwd));
    77 
    78         usr->cwd = getcwd(usr->cwd, PATH_MAX - 1);
    79 
    80         if (NULL == usr->cwd)
    81                 snprintf(usr->cwd, PATH_MAX, "(unknown)");
    82 
    83         if (1 < cli_psprintf(&usr->prompt, "%s # ", usr->cwd)) {
    84                 cli_error(cli_errno, "Failed to set prompt");
    85                 return 1;
    86         }
    87 
    88         return 0;
    89 }
    90 
    9159/* Constructor */
    9260static int cli_init(cliuser_t *usr)
     
    12593
    12694        while (!cli_quit) {
    127                 cli_set_prompt(&usr);
    12895                get_input(&usr);
    12996                if (NULL != usr.line) {
Note: See TracChangeset for help on using the changeset viewer.