Advertisement
Guest User

Untitled

a guest
Aug 27th, 2015
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #!/bin/bash -x
  2.  
  3. function i_know_what_this_does() {
  4. (
  5. set +x
  6. echo do stuff
  7. )
  8. }
  9.  
  10. echo the next-next line still echoes 'set +x', is that avoidable?
  11. i_know_what_this_does
  12. echo and we are back and echoing is back on
  13.  
  14. + echo the next-next line still echoes 'set +x,' is that 'avoidable?'
  15. the next-next line still echoes set +x, is that avoidable?
  16. + i_know_what_this_does
  17. + set +x
  18. do stuff
  19. + echo and we are back and echoing is back on
  20. and we are back and echoing is back on
  21.  
  22. ikwtd() {
  23. echo do stuff
  24. } 2> /dev/null
  25.  
  26. ikwtd() (
  27. set +x
  28. exec 2>&3 3>&-
  29. echo do stuff
  30. ) 3>&2 2> /dev/null
  31.  
  32. function xtrace() {
  33. # Print the line as if xtrace was turned on, using perl to filter out
  34. # the extra colon character and the following "set +x" line.
  35. (
  36. set -x
  37. # Colon is a no-op in bash, so nothing will execute.
  38. : "$@"
  39. set +x
  40. ) 2>&1 | perl -ne 's/^[+] :/+/ and print' 1>&2
  41. # Execute the original line unmolested
  42. "$@"
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement