From: Ben Cox (thoth@uiuc.edu)
Date: 07/09/92


From: thoth@uiuc.edu (Ben Cox)
Subject: Re: Funny bug in 'strings'
Date: Fri, 10 Jul 1992 03:33:28 GMT

fijma@cs.utwente.nl (Duco Fijma) writes:

>I encountered a bug in the 'strings' program, which was in the MCC 0.96c
>distribution. Like many other Unix programs, strings reads a list of files from
>its argv and does something with all these files. strings also includes argv[0]
>in this list, resulting in the program trying to list the strings in its own
>executable. When in directory /usr/bin, where strings is located, you see the
>strings from strings (pfeh...). When in another directory, it prints something
>like 'strings: strings: file not found'.

>It's not a very fatal bug, but I can't imagine nobody saw it before. Or did I
>missed a few articles in this group?

I found this bug, too, and it's easy to fix (I fixed it on my system
with this patch):

==================================cut=here=======================
*** strings.c.old Thu Jul 9 22:27:05 1992
--- strings.c Thu Jul 9 22:27:27 1992
***************
*** 126,131 ****
--- 126,132 ----
                        usage();
                }
        }
+ if ( !optind ) optind++;
        argc -= optind;
        argv += optind;
  
==================================cut=here=======================

Not the most elegant solution, but it works, and it's a one-liner.