Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

piping surprise



Speaking of female logic, I stumbled upon this:

function bbb ()
{
    vvar=4
    print -l "\nShall\nI\ncompare thee\nto a\nsummer's day?"
}    

function aaa ()
{
    local vvar=1
    bbb
    echo "\nvvar is $vvar"
    vvar=2
    echo "\n=============\n"
    bbb | grep 'a'
    echo "\nvvar is $vvar"
}

%  aaa

Shall
I
compare thee
to a
summer's day?

vvar is 4

=============

Shall
compare thee
to a
summer's day?

vvar is 2

------------------------------------------------------------------

By what thinking does the piping of a function's output thru grep cancel the assignment to the variable?  Do we really want that?





Messages sorted by: Reverse Date, Date, Thread, Author