3
0

redir_expand.tests 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. rm *shell_test* 2>/dev/null
  2. >\shell_test
  3. echo *shell_test*
  4. rm *shell_test*
  5. >\\shell_test
  6. echo *shell_test*
  7. rm *shell_test*
  8. >"\shell_test"
  9. echo *shell_test*
  10. rm *shell_test*
  11. >"\\shell_test"
  12. echo *shell_test*
  13. rm *shell_test*
  14. cat <<\shell_test
  15. Here1
  16. shell_test
  17. echo Ok1
  18. cat <<\\shell_test
  19. Here2
  20. \shell_test
  21. echo Ok2
  22. cat <<"\shell_test"
  23. Here3
  24. \shell_test
  25. echo Ok3
  26. cat <<"\\shell_test"
  27. Here4
  28. \shell_test
  29. echo Ok4
  30. echo Now with variable refs
  31. i=1
  32. >\shell_test_$i
  33. echo *shell_test*
  34. rm *shell_test*
  35. >\\shell_test_$i
  36. echo *shell_test*
  37. rm *shell_test*
  38. >"\shell_test_$i"
  39. echo *shell_test*
  40. rm *shell_test*
  41. >"\\shell_test_$i"
  42. echo *shell_test*
  43. rm *shell_test*
  44. echo Done;exit
  45. # UNFIXED BUG. bash apparently will expand $i even in terminating delimiter.
  46. # http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html
  47. # does not mandate this behavior.
  48. # This is not likely to be used much in real-world.
  49. cat <<\shell_test_$i
  50. Here1
  51. shell_test_$i
  52. echo Ok1
  53. cat <<\\shell_test_$i
  54. Here2
  55. \shell_test_$i
  56. echo Ok2
  57. cat <<"\shell_test_$i"
  58. Here3
  59. \shell_test_$i
  60. echo Ok3
  61. cat <<"\\shell_test_$i"
  62. Here4
  63. \shell_test_$i
  64. echo Ok4