/bin/sh => STDIN & functions, var scope messing

Reid Linnemann linnemannr at gmail.com
Tue May 28 15:07:32 UTC 2013


On May 28, 2013, at 7:00 AM, Ryan Stone <rysto32 at gmail.com> wrote:

> On Tue, May 28, 2013 at 5:48 AM, Václav Zeman <vhaisman at gmail.com> wrote:
> Curious. Which of the two behaviours is POSIXly correct?
> 
> I believe that /bin/sh's behaviour is correct.  I don't know what shell the manpage is referring to, but it's not bash (bash does the same thing in a pipeline).  Perhaps it's referring to csh?  If that is the case that line is probably causing more confusion rather than alleviating it.

I believe it's referring to csh, possible ksh as well. I tried a similar experiment with tcsh:

#!/bin/tcsh
alias fn set var=12
set var=
echo $var
yes | fn
echo $var


More information about the freebsd-hackers mailing list