forked from Bananymous/banan-os
Shell: Quick fix to not freeze for multiple seconds
When sync is writing to disk, it reserves whole disk to itself. This commit makes Shell to read username only once from getpwuid(). We used to get username every time prompt was printed.
This commit is contained in:
parent
96b1186c19
commit
6304388100
|
@ -701,11 +701,17 @@ BAN::String get_prompt()
|
||||||
}
|
}
|
||||||
case 'u':
|
case 'u':
|
||||||
{
|
{
|
||||||
auto* passwd = getpwuid(geteuid());
|
static char* username = nullptr;
|
||||||
if (passwd == nullptr)
|
if (username == nullptr)
|
||||||
break;
|
{
|
||||||
MUST(prompt.append(passwd->pw_name));
|
auto* passwd = getpwuid(geteuid());
|
||||||
endpwent();
|
if (passwd == nullptr)
|
||||||
|
break;
|
||||||
|
username = new char[strlen(passwd->pw_name) + 1];
|
||||||
|
strcpy(username, passwd->pw_name);
|
||||||
|
endpwent();
|
||||||
|
}
|
||||||
|
MUST(prompt.append(username));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'h':
|
case 'h':
|
||||||
|
|
Loading…
Reference in New Issue