From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from weaver-gw.netapp.com ([198.95.224.2]) by hawkwind.utcs.utoronto.ca with SMTP id <24740>; Thu, 1 May 1997 17:04:32 -0400 Received: from netapp.com ([192.9.200.1]) by weaver.netapp.com with SMTP id <246204-184>; Thu, 1 May 1997 12:26:46 -0700 Received: by netapp.com (4.1/SMI-4.1) id AA28377; Thu, 1 May 97 12:28:23 PDT Date: Thu, 1 May 1997 15:28:23 -0400 From: byron@netapp.com (Byron Rakitzis) Message-Id: <9705011928.AA28377@netapp.com> To: culliton@clark.net, rc@hawkwind.utcs.toronto.edu, rsc@research.att.com Subject: re: 99 bottles in an rc shell script. How about this way to build a list up: #!/bin/rc fn stack_bottles { count=$1 if (~ $count *[~0-9]* || ~ $count ()) { echo $0: count must be a nonnegative decimal integer >[1=2] exit 1 } bottles=() while (!~ $#bottles $count) bottles=(beer $bottles) echo $bottles } # the rest is cribbed from tom *=`{stack_bottles $*} bottles=$#* one=one while (!~ $#* 0) { echo $bottles 'of beer on the wall,' ; echo $bottles 'of beer,' echo 'take' $one 'down and pass it around,' shift ; switch ($#*) { case 1 ; bottles = '1 bottle' ; one = it case 0 ; bottles = 'no more bottles' case * ; bottles = $#*^' bottles' } echo $bottles 'of beer on the wall.' ; echo }