cvs commit: LFS/lfscmd/src help.c lfscmd.c lfscmd.h

timothy at linuxfromscratch.org timothy at linuxfromscratch.org
Sun Mar 2 19:50:51 PST 2003


timothy     03/03/02 22:50:51

  Modified:    lfscmd   README
               lfscmd/doc lfscmd.1
               lfscmd/src help.c lfscmd.c lfscmd.h
  Log:
  Added -e option to execute commands rather
  than print them.
  
  Revision  Changes    Path
  1.3       +2 -0      LFS/lfscmd/README
  
  Index: README
  ===================================================================
  RCS file: /home/cvsroot/LFS/lfscmd/README,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- README	2 Mar 2003 20:59:30 -0000	1.2
  +++ README	3 Mar 2003 03:50:51 -0000	1.3
  @@ -9,6 +9,8 @@
   	to either stdout or files.
   
   OPTIONS
  +	-e     Execute commands.
  +
   	-f     Write commands to their own file.
   
   	-q query
  
  
  
  1.3       +3 -0      LFS/lfscmd/doc/lfscmd.1
  
  Index: lfscmd.1
  ===================================================================
  RCS file: /home/cvsroot/LFS/lfscmd/doc/lfscmd.1,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- lfscmd.1	2 Mar 2003 20:59:30 -0000	1.2
  +++ lfscmd.1	3 Mar 2003 03:50:51 -0000	1.3
  @@ -12,6 +12,9 @@
   stdout or files.
   .SH OPTIONS
   .TP
  +.B -e
  +Execute commands.
  +.TP
   .B -f
   Write commands to their own file.
   .TP
  
  
  
  1.2       +2 -0      LFS/lfscmd/src/help.c
  
  Index: help.c
  ===================================================================
  RCS file: /home/cvsroot/LFS/lfscmd/src/help.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- help.c	2 Mar 2003 20:59:30 -0000	1.1
  +++ help.c	3 Mar 2003 03:50:51 -0000	1.2
  @@ -27,6 +27,8 @@
   	fprintf(stderr,
   "Usage: %s [options] index.xml\n\
   Options:\n\
  +  -e\n\
  +     Execute commands.\n\
     -f\n\
        Write commands to their own file.\n\
     -q query\n\
  
  
  
  1.2       +18 -5     LFS/lfscmd/src/lfscmd.c
  
  Index: lfscmd.c
  ===================================================================
  RCS file: /home/cvsroot/LFS/lfscmd/src/lfscmd.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- lfscmd.c	2 Mar 2003 20:59:30 -0000	1.1
  +++ lfscmd.c	3 Mar 2003 03:50:51 -0000	1.2
  @@ -21,6 +21,7 @@
   #include <regex.h>
   #include <sys/stat.h>
   #include <unistd.h>
  +#include <stdlib.h>
   
   #include "help.h"
   #include "string.h"
  @@ -34,13 +35,14 @@
   
       /* Set defaults */
       lfs.exe     = 0;
  +    lfs.execute = 0;
       lfs.file    = 0;
       lfs.title   = 0;
       lfs.status  = 0;
       lfs.query   = NULL;
       lfs.xmlfile = NULL;
   
  -    while ((c = getopt (argc, argv, "fxtq:")) != -1)
  +    while ((c = getopt (argc, argv, "fxteq:")) != -1)
       switch(c)
       {
          case 'f':
  @@ -52,6 +54,9 @@
          case 't':
             lfs.title = 1;
             break;
  +       case 'e':
  +          lfs.execute = 1;
  +          break;
          case 'q':
             lfs.query = optarg;
             break;
  @@ -157,16 +162,24 @@
       {
           /* Output content outside of "userinput" */
           if (string_comp("text", node->name)) {
  -            if (NULL != (lfs.cmd = node->content))
  -            fprintf(output, "%s", lfs.cmd);
  +            if (NULL != (lfs.cmd = node->content)) {
  +               if (1 == lfs.execute)
  +               system(lfs.cmd);
  +               else
  +               fprintf(output, "%s", lfs.cmd);
  +            }
           }
   
           /* Output commands */
           else if (string_comp("userinput", node->name)) {
   
               /* Strip double ampersands */
  -            if (NULL != (lfs.cmd = xmlNodeListGetString(doc, node->children, 1)))
  -            fprintf(output, "%s", string_strip(lfs.cmd, "&&"));
  +            if (NULL != (lfs.cmd = xmlNodeListGetString(doc, node->children, 1))) {
  +               if (1 == lfs.execute)
  +               system(string_strip(lfs.cmd, "&&"));
  +               else
  +               fprintf(output, "%s", string_strip(lfs.cmd, "&&"));
  +            }
           }
   
           node = node->next;
  
  
  
  1.2       +1 -1      LFS/lfscmd/src/lfscmd.h
  
  Index: lfscmd.h
  ===================================================================
  RCS file: /home/cvsroot/LFS/lfscmd/src/lfscmd.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- lfscmd.h	2 Mar 2003 20:59:30 -0000	1.1
  +++ lfscmd.h	3 Mar 2003 03:50:51 -0000	1.2
  @@ -4,7 +4,7 @@
   #include <libxml/tree.h>
   
   struct LFSCMD {
  -    int exe, file, title;
  +    int exe, execute, file, title;
       int status;
       char *query, *xmlfile;
       char *cmd, *fname, *sect;
  
  
  
-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe lfs-book' in the subject header of the message



More information about the lfs-book mailing list