From de22fd4b4bdae5eca806851094de6f05f5f270dc Mon Sep 17 00:00:00 2001 From: Roman Date: Sat, 21 Nov 2015 23:13:27 +0100 Subject: [PATCH] SITL shell: do not save command if it replicates the previous one --- src/platforms/posix/main.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/platforms/posix/main.cpp b/src/platforms/posix/main.cpp index 5734839460..6152ff766d 100644 --- a/src/platforms/posix/main.cpp +++ b/src/platforms/posix/main.cpp @@ -247,8 +247,19 @@ int main(int argc, char **argv) buf_ptr_write = 0; } - string_buffer[buf_ptr_write] = mystr; - buf_ptr_write++; + if (buf_ptr_write > 0) { + if (mystr != string_buffer[buf_ptr_write - 1]) { + string_buffer[buf_ptr_write] = mystr; + buf_ptr_write++; + } + + } else { + if (mystr != string_buffer[CMD_BUFF_SIZE - 1]) { + string_buffer[buf_ptr_write] = mystr; + buf_ptr_write++; + } + } + process_line(mystr, !daemon_mode); mystr = ""; buf_ptr_read = buf_ptr_write; @@ -258,8 +269,10 @@ int main(int argc, char **argv) c = getchar(); // skip first one, does not have the info c = getchar(); + // arrow up if (c == 'A') { buf_ptr_read--; + // arrow down } else if (c == 'B') { if (buf_ptr_read < buf_ptr_write) {