rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
From: Robert Earl <chupchup@piggy.ucsb.edu>
To: Chris Siebenmann <cks@hawkwind.utcs.toronto.edu>
Cc: rc@archone.tamu.edu
Subject: Re: today's rc programming challenge
Date: Fri, 17 Apr 1992 06:07:00 -0500	[thread overview]
Message-ID: <9204171207.AA12185@piggy.ucsb.edu> (raw)
In-Reply-To: Your message of "Thu, 16 Apr 92 17:11:48 CDT." <92Apr16.181203edt.2714@hawkwind.utcs.toronto.edu>

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).



  reply	other threads:[~1992-04-17 12:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-04-16 22:11 Chris Siebenmann
1992-04-17 11:07 ` Robert Earl [this message]
1992-04-17 12:34 Arnold D. Robbins
1992-04-17 13:23 rsalz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9204171207.AA12185@piggy.ucsb.edu \
    --to=chupchup@piggy.ucsb.edu \
    --cc=cks@hawkwind.utcs.toronto.edu \
    --cc=rc@archone.tamu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).