home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / gnu / bash / bug / 585 < prev    next >
Encoding:
Text File  |  1992-09-01  |  1.4 KB  |  51 lines

  1. Newsgroups: gnu.bash.bug
  2. Path: sparky!uunet!cis.ohio-state.edu!cs.mu.oz.AU!kre
  3. From: kre@cs.mu.oz.AU (Robert Elz)
  4. Subject: Re: odd 'shift' behaviour with bash-1.1
  5. Message-ID: <9224608.22397@mulga.cs.mu.OZ.AU>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: Computer Science, University of Melbourne, Australia
  8. References: <9208312221.AA21541@igc.apc.org>
  9. Distribution: gnu
  10. Date: Tue, 1 Sep 1992 22:34:16 GMT
  11. Approved: bug-bash@prep.ai.mit.edu
  12. Lines: 37
  13.  
  14. In <9208312221.AA21541@igc.apc.org> scott@igc.apc.org (Scott Weikart) writes:
  15.  
  16. | >Its SOP for shells that when a control statement has I/O redirected
  17.  
  18. | This is not true, in general (last week I wrote a program to test it).
  19.  
  20. | Redirecting stdin or stdout to files doesn't result in use of a sub-shell;
  21.  
  22. My definition of "SOP for shells" is what the Bourne shell does (and
  23. when it matters, often the 7th edition Bourne shell).
  24.  
  25. Here's a simple test using /bin/sh
  26.  
  27. munnari$ f=0
  28. munnari$ for i in a b
  29. > do
  30. > f=1
  31. > done
  32. munnari$ echo $f
  33. 1
  34. munnari$  for i in a b
  35. > do
  36. > f=2
  37. > done </dev/null
  38. munnari$ echo $f
  39. 1
  40.  
  41. The point was that in general its unsafe to assume that a "sh"
  42. type shell will allow you to alter the shell environment in any
  43. way if I/O to a control statement is redirected at all.
  44.  
  45. Some shells may be more liberal in what they allow.  Personally
  46. I don't think I'll be writing many scripts that depend on which version
  47. of which shell I happen to be using.
  48.  
  49. kre
  50.  
  51.