bourne sh, problems with var setting in case/esac
Andy Crump
andyc at bucky.intel.com
Fri Nov 30 03:02:34 AEST 1990
>>>>> On 15 Nov 90 19:05:53 GMT, rdavis at connie.UUCP (Ray Davis) said:
Ray> In <1990Nov15.155604.16714 at usenet.ins.cwru.edu> news at usenet.ins.cwru.edu writes:
>>if i don't pipe esac and not use cat, all is ok, but i want to pipe !
>Sh runs control structures with pipes in a subshell. Variables set in a
>subshell cannot affect the parent's settings.
Ray> It isn't the control structure that is the problem, it's the
Ray> pipe. Note that in ksh (and maybe SVR? sh), the pipe causes a
Ray> subshell, but redirecting the output of the case to a file does
Ray> not. Note also that if you 'cat | case', the case is not in a
Ray> subshell.
I tried this on Intel SVR4 version 2.0 with both ksh and sh and they
behave exactly as everyone describes. The pipe causes a subshell.
You have been zapped by Mr. SubShell.
--
-- Andy Crump
...!tektronix!reed!littlei!andyc | andyc at littlei.intel.com
...!uunet!littlei!andyc | andyc at littlei.uu.net
Disclaimer: Any opinions expressed here are my own and
not representive of Intel Corportation.
More information about the Comp.unix.shell
mailing list