home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume16 / less5 / part04 / vecho.c < prev   
Encoding:
C/C++ Source or Header  |  1988-09-22  |  561 b   |  41 lines

  1. /*
  2.  * This dumb little program emulates the System V "echo" command,
  3.  * to accomodate BSD systems which don't understand the \c escape,
  4.  * meaning don't echo a newline.  BSD uses "echo -n".
  5.  */
  6.  
  7. #include <stdio.h>
  8.  
  9. int putnl;
  10.  
  11. main(argc, argv)
  12.     int argc;
  13.     char *argv[];
  14. {
  15.     putnl = 1;
  16.     while (--argc > 0)
  17.     {
  18.         vecho(*++argv);
  19.         if (argc > 1)
  20.             putchar(' ');
  21.     }
  22.     if (putnl)
  23.         putchar('\n');
  24. }
  25.  
  26. vecho(str)
  27.     char *str;
  28. {
  29.     register char *s;
  30.  
  31.     for (s = str;  *s != '\0';  s++)
  32.     {
  33.         if (*s == '\\' && s[1] == 'c')
  34.         {
  35.             putnl = 0;
  36.             return;
  37.         }
  38.         putchar(*s);
  39.     }
  40. }
  41.