sh: Do not backspace if command is empty

This commit is contained in:
apio 2022-10-20 19:32:32 +02:00
parent b69fbd46bf
commit 0720b3245b

View File

@ -139,11 +139,33 @@ void command_concat(command* cmd, const char* str)
{
while (*str)
{
if (*str == '\b')
{
if (cmd->size == 0)
{
str++;
continue;
}
putchar(*str);
if (*str == '\b') { command_pop(cmd); }
else if (*str == '\n') { command_execute(cmd); }
command_pop(cmd);
}
else if (*str == '\n')
{
if (cmd->size == 0)
{
putchar(*str);
show_prompt();
str++;
continue;
}
putchar(*str);
command_execute(cmd);
}
else
{
putchar(*str);
command_push(cmd, *str);
}
str++;
}
}