Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Declare LOG_DEFAULT_CATEGORY with LOG_NEW_DEFAULT_SUBCATEGORY.
[simgrid.git] / tools / tesh / tesh.c
index 7b1a4c0..15c0053 100644 (file)
@@ -1,9 +1,7 @@
-/* $Id$ */
-
 /* TESH (Test Shell) -- mini shell specialized in running test units        */
 
-/* Copyright (c) 2007 Martin Quinson.                                       */
-/* All rights reserved.                                                     */
+/* Copyright (c) 2007, 2008, 2009, 2010. The SimGrid Team.
+ * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -201,7 +199,7 @@ int main(int argc, char *argv[])
 
   /* Get args */
   for (i = 1; i < argc; i++) {
-    if (!strncmp(argv[i], "--cd", strlen("--cd") + 1)) {
+    if (!strcmp(argv[i], "--cd")) {
       if (i == argc - 1) {
         ERROR0("--cd argument requires an argument");
         exit(1);
@@ -212,8 +210,9 @@ int main(int argc, char *argv[])
         exit(1);
       }
       INFO1("Change directory to %s", argv[i + 1]);
-      memmove(argv + i, argv + i + 2, argc - i - 1);
+      memmove(argv + i, argv + i + 2, (argc - i - 1)*sizeof(char*));
       argc -= 2;
+      i -= 2;
     }
   }
 
@@ -250,6 +249,5 @@ int main(int argc, char *argv[])
   }
 
   rctx_exit();
-  xbt_exit();
   return 0;
 }