Date: Sat, 24 May 1997 05:20:40 +0200 (MET DST) From: Eivind Eklund <perhaps@yes.no> To: Steve Howe <un_x@anchorage.net> Cc: hackers@freebsd.org Subject: Re: pipelines Message-ID: <199705240320.FAA05443@bitbox.follo.net> In-Reply-To: Steve Howe's message of Fri, 23 May 1997 17:19:30 -0800 (AKDT) References: <Pine.BSF.3.95q.970523171443.13536A-100000@aak.anchorage.net>
next in thread | previous in thread | raw e-mail | index | archive | help
I've kept hackers on the Cc: line - if you reply to this, consider moving it to -questions. Thanks. > #!/bin/sh > # invoke with dummy args ... > while [ $1 ]; do t=$(($t + 1)); shift; done | cat; echo X$t > > > is there any way to find the value of a variable that is set in a pipe > ... outside the pipe? i wish i could echo "t"s value in the example > above, but exporting, etc, doesn't seem to help. No possible, AFAIK. Your '| cat' makes a sub-shell, which can't change the variables of the parent. Could you drop it? Otherwise (probably with your subject-line :-), you'll have to use temp-files, ie. #!/bin/sh # invoke with dummy args ... umask 77 if mkdir /tmp/dummy.$$ then export MYCOUNTER=/tmp/dummy.$$/counter echo -n 0 > $MYCOUNTER while [ $1 ] do echo -n $((`cat $MYCOUNTER` + 1)) > $MYCOUNTER shift done | cat echo X`cat $MYCOUNTER` rm -rf /tmp/dummy.$$ else echo "Unable to create temporary directory /tmp/dummy.$$!" exit 1 fi mkdir is to get secure temp-files. > please respond directly - i don't subscribe to hackers ... thanks. And you shouldn't post this there - it belong in -questions. Eivind.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199705240320.FAA05443>