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

Re: exporting a variable to global shells



Alex Samad wrote:
On Mon, May 14, 2007 at 09:13:32AM -0700, Bob McGowan wrote:
cga2000 wrote:
On Fri, May 11, 2007 at 12:33:12PM EDT, Bob McGowan wrote:

<snip>

 3.  in the parent script, where you use your script, change it to be:

<and more snipped>

So:

  $ echo a b c d | read x y z p
  $ echo $x $y $z $p
  a b c d

what about something like

set -- 1 2 3 4 5 6 7
for x
do
	echo $x
done


change 1 2 3 4 5 6 7 for what every number of variables you want ?

---XXX---

Reminder: the original poster wanted to have data passed backward (up the process tree) from a child script to a parent.

Collecting the output of a command using 'command substitution' is most easily handled as a single variable or line of data. You can make the method of passing the data out of the child as complex as you like, but in the calling script:

  lineIn=$(child )

puts one long string in $lineIn, including newline characters, spaces, tabs and so on. The result, using your 'set...loop', would put newline separated numbers into the returned string.

Further processing would then need be done on the string to break it up into pieces, or not, as dictated by the needs of the caller. My 'child | read a b c d' is a quick way to read in the multiple lines output by your method, or to break a long line up on any white space characters. Without using the arrays suggested by another poster, which may not be supported by all versions of Bourne type shells.

Bob

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


Reply to: