Xref: utzoo comp.unix.questions:9591 comp.unix.wizards:11569 Path: utzoo!utgpu!attcan!uunet!steinmetz!davidsen From: davidsen@steinmetz.ge.com (William E. Davidsen Jr) Newsgroups: comp.unix.questions,comp.unix.wizards Subject: {} grouping in sh and ksh Message-ID: <12306@steinmetz.ge.com> Date: 5 Oct 88 13:57:09 GMT Reply-To: davidsen@crdos1.UUCP (bill davidsen) Followup-To: comp.unix.wizards Organization: GE Corp. R & D, Schenectady,NY Lines: 31 I recently posted an answer to a question and have been told that me reply is true for ksh, but not for sh. Let me clarify the action of both shells. I tested the sh operation on both V.2 and V7, so I am reasonably certain of the action. In sh, actions grouped by {} delimiters will be treated as a unit and may be used with &&, ||, and redirection. If redirection is used the commands will be executed in a subshell. After the commands have been run, if a subshell is not used the working directory is reset, such that it always works as if a subshell were used. Ex: { cd ..; ps -l; pwd; ps -l; } && pwd { cd ..; ps -l; pwd; ps -l; } > x && pwd In the example with redirection the first ps will show a subshell running. Even if a subshell is used, the last command is execed without a fork, so the second ps will *never* show a subshell. This muddied the water when I was investigating the action. In ksh a subshell is never used. After execution of the commands the working directory is not reset. This is exactly as documented. The examples above will produce the same output. I apologize if this mislead anyone, I know how ksh works, and a simple test with sh before my last posting didn't show the details. -- bill davidsen (wedu@ge-crd.arpa) {uunet | philabs}!steinmetz!crdos1!davidsen "Stupidity, like virtue, is its own reward" -me