rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
* Re: here strings
@ 1993-06-05 16:42 Alan Watson
  0 siblings, 0 replies; 5+ messages in thread
From: Alan Watson @ 1993-06-05 16:42 UTC (permalink / raw)
  To: John Mackin; +Cc: rc

Sorry, John, but I'm not convinced by your example, although there may
be something I have missed.

The precise behaviour of your example can be reproduced by:

   for ( f in * ) mv $f `{ echo -n $f | tr A-Z a-z }

assuming echo is built-in (or an external, non-SYSV echo).  I strongly
suspect that your here-string solution is not very much faster than
this one, if echo is a built-in command.  So, I would tentatively class
your idiom as a speed hack on a system without a built-in echo (like
some of the means of getting at the file system through the globber and
builtin cd).

As I see it, the justification for here-strings is that echo is not a
necessarily available as a built-in, and so one cannot reliably convert
a here-document to a a series of echoes.


^ permalink raw reply	[flat|nested] 5+ messages in thread
[parent not found: <john@civil.su.oz.au>]
* Re: here strings
@ 1993-06-05 12:53 malte
  1993-06-05 12:55 ` John Mackin
  0 siblings, 1 reply; 5+ messages in thread
From: malte @ 1993-06-05 12:53 UTC (permalink / raw)
  To: rc

	a directory full of files that had come from, ah, another operating
	system, and the names were all upper-case:

		for (f in *) mv $f `{tr A-Z a-z <<<$f}

	OK,
	John.

Your lucky this worked because most (especially on older unixes) text
utilities require their input to end in a '\n'. Then you'd have to

		for (f in *) mv $f `{echo $f | tr A-Z a-z}

Malte



^ permalink raw reply	[flat|nested] 5+ messages in thread
* here strings
@ 1993-06-05 12:35 John Mackin
  0 siblings, 0 replies; 5+ messages in thread
From: John Mackin @ 1993-06-05 12:35 UTC (permalink / raw)
  To: The rc Mailing List; +Cc: The es Mailing List

Hands off here strings, you unprincipled boors!  Real Example time
(flog that dead horse, I know, but this was too good not to mail,
and the old hands know how I feel about Real Examples): I had
a directory full of files that had come from, ah, another operating
system, and the names were all upper-case:

	for (f in *) mv $f `{tr A-Z a-z <<<$f}

(Adjust your brain, and your $home/bin, as needed if your tr is infected
with the SysVile square-bracket virus... they're _not_ character classes!)

OK,
John.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1993-06-07  8:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1993-06-05 16:42 here strings Alan Watson
     [not found] <john@civil.su.oz.au>
1993-06-07  8:42 ` malte
  -- strict thread matches above, loose matches on Subject: below --
1993-06-05 12:53 malte
1993-06-05 12:55 ` John Mackin
1993-06-05 12:35 John Mackin

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