Advertisement
Guest User

Untitled

a guest
May 3rd, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. x=1
  4. echo fred>junk ; while read var ; do x=55 ; done <junk
  5. echo x=$x
  6. # x=55 .. I'd expect this result
  7.  
  8. x=1
  9. cat junk | while read var ; do x=55 ; done
  10. echo x=$x
  11. # x=1 .. but why?
  12.  
  13. x=1
  14. echo fred | while read var ; do x=55 ; done
  15. echo x=$x
  16. # x=1 .. but why?
  17.  
  18. a=0; a=1 | a=2; echo $a
  19.  
  20. cat junk | {
  21. while read var ; do x=55 ; done
  22. echo x=$x
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement