Simple embedded shell with runtime pluggable commands.

Dependents:   DataBus2018

Implements a simple unix-like shell for embedded systems with a pluggable command architecture.

Revision:
33:84dc443909a0
Parent:
32:fc09f0eb1e8a
Child:
34:afe994ca0e49
--- a/SimpleShell.cpp	Fri Dec 28 19:54:48 2018 +0000
+++ b/SimpleShell.cpp	Fri Dec 28 20:08:22 2018 +0000
@@ -105,14 +105,12 @@
 
 
 char *SimpleShell::basename(char *path) {
-    char *result = path + strlen(path);
+    char *result = strrchr(path, '/');
     
-    while (result != path) {
-        if (*result == '/') {
-            result++;
-            break;
-        }
-        result--;
+    if (result == NULL) {
+        result = path;
+    } else {
+        if (result[0] == '/') result++;
     }
     
     return result;
@@ -214,7 +212,15 @@
 {
     if (argc >= 2) {
         for (int i=1; i < argc; i++) {
-            if (haswildcard(argv[i])) {
+            char *arg = canon(argv[i]);
+            char *base = basename(arg);
+
+            printf("arg=<%s>\nbase=<%s>\n", arg, base);
+            return;
+        }
+
+/*            
+            if (haswildcard(arg) {
                 list<char*> *fl = scandir(argv[i], _cwd);
                 char *s;
                 while (!fl->empty()) {
@@ -229,7 +235,7 @@
                     printf("%s: cannot remove\n", argv[i]);
                 }
             }
-        }
+        }*/ 
     } else {
         puts("usage: rm [file1 [file2 ...]]");
     }