|
@@ -49,7 +49,7 @@ void EShRunLoop() {
|
|
|
strcpy(uncomplete_command, command);
|
|
|
}
|
|
|
|
|
|
- char* new_command = EShReceiveCommandFromHistory(current_history_step);
|
|
|
+ const char* new_command = EShReceiveCommandFromHistory(current_history_step);
|
|
|
if (new_command != NULL) {
|
|
|
++current_history_step;
|
|
|
for (int i = current_command_pos; i < command_length; ++i) {
|
|
@@ -69,13 +69,11 @@ void EShRunLoop() {
|
|
|
printf("%c", command[i]);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- free(new_command);
|
|
|
break;
|
|
|
}
|
|
|
case 'B': // Down
|
|
|
{
|
|
|
- char* new_command;
|
|
|
+ const char* new_command;
|
|
|
|
|
|
if (current_history_step > 0) {
|
|
|
--current_history_step;
|
|
@@ -104,9 +102,6 @@ void EShRunLoop() {
|
|
|
printf("%c", command[i]);
|
|
|
}
|
|
|
|
|
|
- if (current_history_step > 0) {
|
|
|
- free(new_command);
|
|
|
- }
|
|
|
break;
|
|
|
}
|
|
|
case 'C': // Right
|
|
@@ -190,6 +185,9 @@ void EShRunLoop() {
|
|
|
EShExecuteJobs(jobs_num, jobs);
|
|
|
}
|
|
|
|
|
|
+ free(command);
|
|
|
+ free(uncomplete_command);
|
|
|
+
|
|
|
/* restore the original terminal attributes */
|
|
|
tcsetattr(fileno(stdin), TCSANOW, &orig_term_attr);
|
|
|
}
|