3
0

recho.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 main(int argc, char **argv)
  24. {
  25. int i;
  26. for (i = 1; i < argc; i++) {
  27. printf("argv[%d] = <", i);
  28. strprint(argv[i]);
  29. printf(">\n");
  30. }
  31. exit(EXIT_SUCCESS);
  32. }
  33. void strprint(char *str)
  34. {
  35. unsigned char *s;
  36. for (s = (unsigned char *)str; s && *s; s++) {
  37. if (*s < ' ') {
  38. putchar('^');
  39. putchar(*s+64);
  40. } else if (*s == 127) {
  41. putchar('^');
  42. putchar('?');
  43. } else
  44. putchar(*s);
  45. }
  46. }