NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: /bin/sh question



On Jul 29, 2012, at 9:28 AM, Paul Goyette wrote:

> Just out of curiousity, is there a reason why the following does not work?  
> It generates "Symbol =" as output...
> 
>       #! /bin/sh
> 
>       echo "value" |
>         read symbol
>       echo "Symbol = $symbol"
> 
> Yet it does work if you do it as follows, generating the expected output 
> "Symbol = value"
> 
>       #! /bin/sh
>       echo "value" |
>       ( read symbol
>         echo "Symbol = $symbol" )

The | forces a subshell which will discard the value symbol when it exits



Home | Main Index | Thread Index | Old Index