home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.bash.bug
- Path: sparky!uunet!cis.ohio-state.edu!cs.mu.oz.AU!kre
- From: kre@cs.mu.oz.AU (Robert Elz)
- Subject: Re: odd 'shift' behaviour with bash-1.1
- Message-ID: <9224608.22397@mulga.cs.mu.OZ.AU>
- Sender: gnulists@ai.mit.edu
- Organization: Computer Science, University of Melbourne, Australia
- References: <9208312221.AA21541@igc.apc.org>
- Distribution: gnu
- Date: Tue, 1 Sep 1992 22:34:16 GMT
- Approved: bug-bash@prep.ai.mit.edu
- Lines: 37
-
- In <9208312221.AA21541@igc.apc.org> scott@igc.apc.org (Scott Weikart) writes:
-
- | >Its SOP for shells that when a control statement has I/O redirected
-
- | This is not true, in general (last week I wrote a program to test it).
-
- | Redirecting stdin or stdout to files doesn't result in use of a sub-shell;
-
- My definition of "SOP for shells" is what the Bourne shell does (and
- when it matters, often the 7th edition Bourne shell).
-
- Here's a simple test using /bin/sh
-
- munnari$ f=0
- munnari$ for i in a b
- > do
- > f=1
- > done
- munnari$ echo $f
- 1
- munnari$ for i in a b
- > do
- > f=2
- > done </dev/null
- munnari$ echo $f
- 1
-
- The point was that in general its unsafe to assume that a "sh"
- type shell will allow you to alter the shell environment in any
- way if I/O to a control statement is redirected at all.
-
- Some shells may be more liberal in what they allow. Personally
- I don't think I'll be writing many scripts that depend on which version
- of which shell I happen to be using.
-
- kre
-
-