3
0

recho.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. recho -- really echo args, bracketed with <> and with invisible chars
  3. made visible.
  4. Chet Ramey
  5. chet@po.cwru.edu
  6. */
  7. /* Copyright (C) 2002-2005 Free Software Foundation, Inc.
  8. This file is part of GNU Bash, the Bourne Again SHell.
  9. Bash is free software; you can redistribute it and/or modify it under
  10. the terms of the GNU General Public License as published by the Free
  11. Software Foundation; either version 2, or (at your option) any later
  12. version.
  13. Bash is distributed in the hope that it will be useful, but WITHOUT ANY
  14. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  15. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  16. for more details.
  17. You should have received a copy of the GNU General Public License along
  18. with Bash; see the file COPYING. If not, write to the Free Software
  19. Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
  20. #include <stdio.h>
  21. #include <stdlib.h>
  22. void strprint();
  23. int
  24. main(argc, argv)
  25. int argc;
  26. char **argv;
  27. {
  28. register int i;
  29. for (i = 1; i < argc; i++) {
  30. printf("argv[%d] = <", i);
  31. strprint(argv[i]);
  32. printf(">\n");
  33. }
  34. exit(EXIT_SUCCESS);
  35. }
  36. void
  37. strprint(str)
  38. char *str;
  39. {
  40. register unsigned char *s;
  41. for (s = (unsigned char *)str; s && *s; s++) {
  42. if (*s < ' ') {
  43. putchar('^');
  44. putchar(*s+64);
  45. } else if (*s == 127) {
  46. putchar('^');
  47. putchar('?');
  48. } else
  49. putchar(*s);
  50. }
  51. }