tags 691221 + patch
thanks

        Also to note is that even when tree's output indicates an usage
        error, its exit code is zero.  E. g.:

$ tree -d -- ; echo $? 
tree: Invalid argument -`-'.
usage: tree [-acdfghilnpqrstuvxACDFQNSUX] [-H baseHREF] [-T title ] [-L level 
[-R]]
        [-P pattern] [-I pattern] [-o filename] [--version] [--help] [--inodes]
        [--device] [--noreport] [--nolinks] [--dirsfirst] [--charset charset]
        [--filelimit[=]#] [--si] [--timefmt[=]<f>] [<directory list>]
0
$ 

        Please consider the patches MIME'd, which, I believe, will
        remedy both this issue, and the ones mentioned in #691221
        previously.

        TIA.

-- 
FSF associate member #7257
Author: Ivan Shmakov <oneing...@gmail.com>
Bug-Debian: http://bugs.debian.org/691221
Description: Set non-zero exit code on failure.
 Instead of calling exit (0) in usage () unconditionally, only do so if
 the argument is >= 2, allowing exit (1) later in main ().
Last-Update: 2012-10-29
--- a/tree.c
+++ b/tree.c
@@ -247,7 +247,10 @@ int main(int argc, char **argv)
 	  break;
 	case '-':
 	  if (j == 1) {
-	    if (!strcmp("--help",argv[i])) usage(2);
+	    if (!strcmp("--help",argv[i])) {
+	      usage(2);
+	      exit(0);
+	    }
 	    if (!strcmp("--version",argv[i])) {
 	      char *v = version+12;
 	      printf("%.*s\n",(int)strlen(v)-1,v);
@@ -518,7 +521,8 @@
 	"\t[-P pattern] [-I pattern] [-o filename] [--version] [--help] [--inodes]\n"
 	"\t[--device] [--noreport] [--nolinks] [--dirsfirst] [--charset charset]\n"
 	"\t[--filelimit[=]#] [--si] [--timefmt[=]<f>] [<directory list>]\n");
-  if (n < 2) exit(0);
+  if (n < 2)
+    return;
   fprintf(stderr,
 	"  ------- Listing options -------\n"
 	"  -a            All files are listed.\n"
Author: Ivan Shmakov <oneing...@gmail.com>
Bug-Debian: http://bugs.debian.org/691221
Description: Direct --help output to stdout (was: stderr.)
Last-Update: 2012-10-29
--- a/tree.c
+++ b/tree.c
@@ -516,14 +516,15 @@
 
 void usage(int n)
 {
-  fprintf(stderr,
+  FILE *fp = (n < 2 ? stderr : stdout);
+  fprintf(fp,
 	"usage: tree [-acdfghilnpqrstuvxACDFQNSUX] [-H baseHREF] [-T title ] [-L level [-R]]\n"
 	"\t[-P pattern] [-I pattern] [-o filename] [--version] [--help] [--inodes]\n"
 	"\t[--device] [--noreport] [--nolinks] [--dirsfirst] [--charset charset]\n"
 	"\t[--filelimit[=]#] [--si] [--timefmt[=]<f>] [<directory list>]\n");
   if (n < 2)
     return;
-  fprintf(stderr,
+  fprintf(fp,
 	"  ------- Listing options -------\n"
 	"  -a            All files are listed.\n"
 	"  -d            List directories only.\n"
Author: Ivan Shmakov <oneing...@gmail.com>
Bug-Debian: http://bugs.debian.org/691221
Description: Implement the "--" POSIX option terminator.
Last-Update: 2012-10-29
--- a/tree.c
+++ b/tree.c
@@ -75,6 +75,7 @@ int main(int argc, char **argv)
   char sizebuf[64];
   off_t size = 0;
   mode_t mt;
+  int opt_p;
 
   q = p = dtotal = ftotal = 0;
   aflag = dflag = fflag = lflag = pflag = sflag = Fflag = uflag = gflag = FALSE;
@@ -107,9 +108,10 @@ int main(int argc, char **argv)
   memset(gtable,0,sizeof(gtable));
   memset(itable,0,sizeof(itable));
 
+  opt_p = TRUE;
   for(n=i=1;i<argc;i=n) {
     n++;
-    if (argv[i][0] == '-' && argv[i][1]) {
+    if (opt_p && argv[i][0] == '-' && argv[i][1]) {
       for(j=1;argv[i][j];j++) {
 	switch(argv[i][j]) {
 	case 'N':
@@ -247,6 +249,10 @@ int main(int argc, char **argv)
 	  break;
 	case '-':
 	  if (j == 1) {
+	    if (!strcmp("--", argv[i])) {
+	      opt_p = FALSE;
+	      break;
+	    }
 	    if (!strcmp("--help",argv[i])) {
 	      usage(2);
 	      exit(0);
Author: Ivan Shmakov <oneing...@gmail.com>
Bug-Debian: http://bugs.debian.org/691221
Description: Properly describe "-S" as the option to switch to CP437.
 This option was improperly described as using "ASCII" characters to
 draw the tree.
Last-Update: 2012-10-29
--- a/tree.c
+++ b/tree.c
@@ -570,7 +570,7 @@ void usage(int n)
 	"  ------- Graphics options ------\n"
 	"  -i            Don't print indentation lines.\n"
 	"  -A            Print ANSI lines graphic indentation lines.\n"
-	"  -S            Print with ASCII graphics indentation lines.\n"
+	"  -S            Print with CP437 graphics indentation lines.\n"
 	"  -n            Turn colorization off always (-C overrides).\n"
 	"  -C            Turn colorization on always.\n"
 	"  ------- XML/HTML options -------\n"

Reply via email to