home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!pacsoft!mike
- From: mike@pacsoft.com (Mike Stefanik)
- Newsgroups: comp.unix.shell
- Subject: Re: Handling of '&' by shell
- Message-ID: <1479@pacsoft.com>
- Date: 29 Dec 92 18:02:42 GMT
- References: <1992Dec28.162641.11402@pt.com>
- Organization: Pacific Software Group, Riverside, CA
- Lines: 24
-
- In article <1992Dec28.162641.11402@pt.com> mliu@pt.com (Fred Liu) writes:
- >I am just wondering why the shell creates a background process first if
- >the '&' is at the end of a command line. It would be nice to have the
- >shell check the command first and then fire up the process. [...]
-
- What happens when you're dealing with something more complex than a
- single command and it's arguments. For example:
-
- $ ( while read line; do echo $line; done < file ) | wc -l &
-
- Now certainly, the shell could go through all sorts of gyrations to make
- sure that the `while' loop is correctly formed and that the `wc' program
- actually exists. Consider if there was more than an `echo' inside the
- above loop -- for example, what if there was another nested loop similar
- to the one above?
-
- What happens is that you have made a relatively simple function in the
- shell (ie: forking in the background) an order of magnitude more complex,
- for no better reason than aesthetics. IMHO, it is far better to fork and
- let the child shell do it's own complaining.
-
- --
- Mike Stefanik mike@pacsoft.com ...!uunet!pacsoft!mike (909) 681-2623
- Pacific Software Group, Riverside, CA
-