From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: From: erik quanstrom Date: Sun, 6 Aug 2006 00:18:11 -0500 To: 9fans@cse.psu.edu Subject: Re: [9fans] rc break In-Reply-To: <65e36c043167477045d47b3d99da4b64@plan9.bell-labs.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: 97b7816e-ead1-11e9-9d60-3106f5b1d025 it looks like there are a number of cases in /rc/bin. try "grep -n while". most of them are argument parsing. but then again, argument parsing is a large part of what scripts do. the lack of a break also limits one from doing anything like this: (snippit from an ancient byron's rc script for calculating the date n days in the future.) # figure out what day we have by subtraction j = (Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec) c = () for (i in 31 $feb 31 30 31 30 31 31 30 31 30 31) { c = ($c 1) if ( expr $i '>' $d >/dev/null) { break } d = `{expr $d - $i} } perhaps something like catch(done){ for(i) switch($i){ case -x xflag = 1; case -y yflag = 1; case * raise done } would be better to implement. - erik On Sat Aug 5 18:43:19 CDT 2006, geoff@plan9.bell-labs.com wrote: > I think this will work (modified from an rc script of mine): > > while (! ~ $#* 0 && ~ $1 -* && ! ~ $1 --) { > switch ($1) { > case -a; destsonly=yes > case -b; copies=($copies $2) ; shift > case -c; copies=($copies $user) > case -v; verbose=yes > case -* > echo usage: $0 '[-acv] [-b bcc] [file]...' >[1=2] > exit usage > } > shift > } > # process $*, which now lacks options ... > > I think this is the only situation in which I used to wish for `break' > in rc, but it no longer seems worthwhile.