Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: SimpleShell.cpp
- Revision:
- 5:8f486f4d29d3
- Parent:
- 4:8b8fa59d0015
- Child:
- 8:41b7274a9753
- Child:
- 10:c3faa7ffd23b
diff -r 8b8fa59d0015 -r 8f486f4d29d3 SimpleShell.cpp
--- a/SimpleShell.cpp Sun Dec 02 17:20:15 2018 +0000
+++ b/SimpleShell.cpp Sun Dec 02 17:33:07 2018 +0000
@@ -1,4 +1,5 @@
#include "SimpleShell.h"
+#include <ctype.h>
SimpleShell::SimpleShell()
{
@@ -9,6 +10,7 @@
{
bool done=false;
Callback<void()> cb;
+ int status; // TODO implement command status return
strcpy(_cwd, "/log");
@@ -16,12 +18,12 @@
while (!done) {
printPrompt();
readCommand();
- if (cb = findCommand()) {
- printf("found\n");
- // status = cb.call();
- // done = status == EXIT
- } else {
- printf("command not found\n");
+ if (cmd[0]) { // skip blank command
+ if (cb = findCommand()) {
+ cb.call();
+ } else {
+ printf("command <%s> not found\n", cmd);
+ }
}
}
puts("exiting shell\n");
@@ -98,5 +100,12 @@
} while (!done);
fputc('\n', stdout);
+ // chomp
+ for (int j=i; j >= 0; j--) {
+ if (isspace(cmd[j])) {
+ cmd[j] = '\0';
+ }
+ }
+
return;
}
\ No newline at end of file