Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 4647 → Rev 4648

/trunk/uspace/app/bdsh/util.c
53,14 → 53,6
* string */
unsigned int cli_set_prompt(cliuser_t *usr)
{
usr->prompt = (char *) realloc(usr->prompt, PATH_MAX);
if (NULL == usr->prompt) {
cli_error(CL_ENOMEM, "Can not allocate prompt");
cli_errno = CL_ENOMEM;
return 1;
}
memset(usr->prompt, 0, sizeof(usr->prompt));
 
usr->cwd = (char *) realloc(usr->cwd, PATH_MAX);
if (NULL == usr->cwd) {
cli_error(CL_ENOMEM, "Can not allocate cwd");
67,13 → 59,11
cli_errno = CL_ENOMEM;
return 1;
}
memset(usr->cwd, 0, sizeof(usr->cwd));
 
usr->cwd = getcwd(usr->cwd, PATH_MAX - 1);
 
if (NULL == usr->cwd)
if (!getcwd(usr->cwd, PATH_MAX))
snprintf(usr->cwd, PATH_MAX, "(unknown)");
 
if (usr->prompt)
free(usr->prompt);
asprintf(&usr->prompt, "%s # ", usr->cwd);
 
return 0;