home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / LESS177.ZIP / src / vecho.c < prev    next >
C/C++ Source or Header  |  1992-07-18  |  710b  |  50 lines

  1. /*
  2.  * This dumb little program emulates the System V "echo" command,
  3.  * to accommodate 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. #if OS2
  10. #include "glob.h"
  11. #endif
  12.  
  13. int putnl;
  14.  
  15. main(argc, argv)
  16.     int argc;
  17.     char *argv[];
  18. {
  19. #if OS2
  20.         if (argc > 1)
  21.         GLOBARGS
  22. #endif
  23.     putnl = 1;
  24.     while (--argc > 0)
  25.     {
  26.         vecho(*++argv);
  27.         if (argc > 1)
  28.             putchar('\t');
  29.     }
  30.     if (putnl)
  31.         putchar('\n');
  32.     exit(0);
  33. }
  34.  
  35. vecho(str)
  36.     char *str;
  37. {
  38.     register char *s;
  39.  
  40.     for (s = str;  *s != '\0';  s++)
  41.     {
  42.         if (*s == '\\' && s[1] == 'c')
  43.         {
  44.             putnl = 0;
  45.             return;
  46.         }
  47.         putchar(*s);
  48.     }
  49. }
  50.