From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from piggy.ucsb.edu ([128.111.72.50]) by archone.tamu.edu with SMTP id <45319>; Fri, 17 Apr 1992 07:07:25 -0500 Return-Path: Received: from localhost.ucsb.edu by piggy.ucsb.edu via SMTP (Sendmail 5.65b/1.05) id AA12185; Fri, 17 Apr 92 05:07:06 -0700 Message-Id: <9204171207.AA12185@piggy.ucsb.edu> To: Chris Siebenmann Cc: rc@archone.tamu.edu Subject: Re: today's rc programming challenge In-Reply-To: Your message of "Thu, 16 Apr 92 17:11:48 CDT." <92Apr16.181203edt.2714@hawkwind.utcs.toronto.edu> Date: Fri, 17 Apr 1992 06:07:00 -0500 From: Robert Earl fn chop { l=() { for (f in ``$nl{whatis $1}) { ~ $#l 0 || echo -n $l ~ $f '''' && {echo ''''; return} ~ $#l 0 || echo l=$f } } } you call it with a variable name rather than the value; and it prints a variable assignment a la `whatis' on stdout, so to use it: ; foo='testing chop. ' ; eval ``(){chop foo} and foo is now chopped. i know the calling syntax is obscure, but using whatis was convenient - it knows how to quote, and in the presence of tabs and spaces, echo could get things wrong. OBChallenge: make this work with more than one argument. i had to use "return" to cut out of the loop (which is why it HAS to be in a function).