[bash] fucn | grep '^' - Linux

Table of Contents

##inside shell:
function func()
{
# do someting
VARI=1
}
##

##input
func | grep '^'
echo $VARI
##

##output

##

why not display "1"?

--
劍客 - 賈島 ╭═ ███╰══════════════╮
十年磨一劍,霜刃未曾試。 ███ ███ ▉██ ▉██
今日把示君,誰有不平事? ███ ███ ███ ███
██▉ ▇▇█ ███ ███
██▉ ▉██ █▉█ █▉█
╰╮ ███ █▉█ █▉█ █▉█

--

All Comments

Jacob avatarJacob2011-02-27
你的func沒有return值阿! 他只有定義
Isla avatarIsla2011-03-02
對不起我好像誤會了= =
Daph Bay avatarDaph Bay2011-03-03
echo $VARI|grep '^'
Mary avatarMary2011-03-07
好像是因為pipe裡的東西是用subprocess跑的,才能用kernel提
Edward Lewis avatarEdward Lewis2011-03-09
供的 pipe() 的樣子
Kristin avatarKristin2011-03-12
subprocess結柬時沒有把vari回給parrent
Rachel avatarRachel2011-03-15
我本來以為 pipe 應該是純粹 move stdout to stdin
Sierra Rose avatarSierra Rose2011-03-16
可是要把function的stdout接到grep的stdin裡,function好像要
Daniel avatarDaniel2011-03-17
在另一個process才可以的樣子(和程式不熟,看strace猜的)