Whamcloud - gitweb
mke2fs: make sure bg 0's unused inode count field is zero'ed for mke2fs -S
[tools/e2fsprogs.git] / lib / ss / execute_cmd.c
index 74b5969..53c10c9 100644 (file)
@@ -1,16 +1,33 @@
 /*
  * Copyright 1987, 1988, 1989 by Massachusetts Institute of Technology
  *
- * For copyright info, see copyright.h.
+ * Permission to use, copy, modify, and distribute this software and
+ * its documentation for any purpose is hereby granted, provided that
+ * the names of M.I.T. and the M.I.T. S.I.P.B. not be used in
+ * advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission.  M.I.T. and the
+ * M.I.T. S.I.P.B. make no representations about the suitability of
+ * this software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
  */
 
+#include "config.h"
 #ifdef HAS_STDLIB_H
 #include <stdlib.h>
 #endif
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#else
+extern int errno;
+#endif
 #include "ss_internal.h"
-#include "copyright.h"
 #include <stdio.h>
 
+static int check_request_table PROTOTYPE((ss_request_table *rqtbl, int argc,
+                                         char *argv[], int sci_idx));
+static int really_execute_command PROTOTYPE((int sci_idx, int argc,
+                                            char **argv[]));
+
 /*
  * get_request(tbl, idx)
  *
@@ -190,7 +207,7 @@ int ss_execute_line (sci_idx, line_ptr)
     char *line_ptr;
 {
     char **argv;
-    int argc;
+    int argc, ret;
 
     /* flush leading whitespace */
     while (line_ptr[0] == ' ' || line_ptr[0] == '\t')
@@ -202,16 +219,21 @@ int ss_execute_line (sci_idx, line_ptr)
             return SS_ET_ESCAPE_DISABLED;
         else {
             line_ptr++;
-            system(line_ptr);
-           return 0;
+            return (system(line_ptr) < 0) ? errno : 0;
         }
     }
 
     /* parse it */
     argv = ss_parse(sci_idx, line_ptr, &argc);
-    if (argc == 0)
+    if (argc == 0) {
+       free(argv);
         return 0;
+    }
 
     /* look it up in the request tables, execute if found */
-    return really_execute_command (sci_idx, argc, &argv);
+    ret = really_execute_command (sci_idx, argc, &argv);
+
+    free(argv);
+
+    return(ret);
 }