rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
* Re: a feature I wish rc had
@ 1992-11-03 22:32 Paul Haahr
  1992-11-03 22:43 ` Mark-Jason Dominus
  0 siblings, 1 reply; 7+ messages in thread
From: Paul Haahr @ 1992-11-03 22:32 UTC (permalink / raw)
  To: rsalz; +Cc: es, rc

yes, these are all good suggestions, but they don't feel right
to me.  what i want is some notation for saying

	save (*.[ch] - y.tab.c xxx.*)

while, of course, would generate all .c and .h files other than
y.tab.c and anything that matched xxx.*.  note that, in this
hypothetical, the things after the - are not glob expaned but
just used to filter the list.

and while i could probably come up with a remove operation that
had the same semantics, it's missing the notational convenience.
on the other hand, i'm not sure i'd want to use a shell that had
such syntax in it.

(by the way:  i tend to dislike using eval to get around the
meta-character rules, but that's just my hangup.)


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

* Re: a feature I wish rc had
  1992-11-03 22:32 a feature I wish rc had Paul Haahr
@ 1992-11-03 22:43 ` Mark-Jason Dominus
  0 siblings, 0 replies; 7+ messages in thread
From: Mark-Jason Dominus @ 1992-11-03 22:43 UTC (permalink / raw)
  To: Paul Haahr; +Cc: rc


> 	save (*.[ch] - y.tab.c xxx.*)
> 
> note that, in this hypothetical, the things after the - are not glob
> expanded

Why not?

Consider a `set-subtract' command, which is a little like `echo'.

	set-subtract [foo]... - [bar]...

echoes all the words that are on the left of the `-' but not on the
right. Then instead of

> 	save (               *.[ch] - y.tab.c xxx.* )

use
	save `{ set-subtract *.[ch] - y.tab.c xxx.* }

The globbing is just what you want.



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

* Re: a feature I wish rc had
  1992-11-02 22:36 Paul Haahr
@ 1992-11-04  1:26 ` Scott Schwartz
  0 siblings, 0 replies; 7+ messages in thread
From: Scott Schwartz @ 1992-11-04  1:26 UTC (permalink / raw)
  To: Paul Haahr; +Cc: Chris Siebenmann, es mailing list, rc mailing list


| i've always wanted this in a shell, but never found a convenient notation  
| for it.  if someone can suggest one, it's certainly a potential es feature.

One idea is to add list comprehensions to your language.  List
comprehensions are the list version of set builder notation.  They have
the same power as nested for loops, but with a more compact syntax.



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

* Re: a feature I wish rc had
@ 1992-11-03 19:53 rsalz
  0 siblings, 0 replies; 7+ messages in thread
From: rsalz @ 1992-11-03 19:53 UTC (permalink / raw)
  To: cks, culliton, haahr; +Cc: es, rc

>Anybody feel like producing an all builtin function for this? 
>Something like "remove pattern list" or "remove index list".  It
>shouldn't be too hard.
Trivial:
fn remove { pat=() i=() list=() {
    pat=$1
    shift || { echo 'Usage erorr' >[1=2] ; return 1; }
    for (i) eval ~ $i $pat || list=($list $i)
    echo $list
} }
remove '*.c' foo.c bar baz.c

path=`{remove /usr/share/bin $path}


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

* Re: a feature I wish rc had
@ 1992-11-03 16:10 Tom Culliton x2278
  0 siblings, 0 replies; 7+ messages in thread
From: Tom Culliton x2278 @ 1992-11-03 16:10 UTC (permalink / raw)
  To: cks, haahr; +Cc: es, rc

>> It would be especially powerful if one could take things
>> out of implicit lists, ie say 'all filenames of this pattern, except
>> filenames of that pattern' conveniently.
	
>i've always wanted this in a shell, but never found a convenient notation  
>for it.  if someone can suggest one, it's certainly a potential es feature.
>
>i just use ``ls|grep -v'' usually.

I usually use sed to do this kind of list manipulation, for example
when we have net problems one of the following works quite well to pull
the NFS mounted partions out of my path.

	path=`{echo $path | sed 's:/usr/share/bin::'}

	eval `{whatis path | sed 's:/usr/share/bin::'}

The second could easily be turned into a general function to do the
job, but being able to fetch it out of my history makes that more
bother (and clutter in the environment) than it's worth.

Anybody feel like producing an all builtin function for this? 
Something like "remove pattern list" or "remove index list".  It
shouldn't be too hard.


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

* Re: a feature I wish rc had
@ 1992-11-02 22:36 Paul Haahr
  1992-11-04  1:26 ` Scott Schwartz
  0 siblings, 1 reply; 7+ messages in thread
From: Paul Haahr @ 1992-11-02 22:36 UTC (permalink / raw)
  To: Chris Siebenmann; +Cc: es mailing list, rc mailing list

> rc has convenient ways of adding things to a list, but it has
> no particularly easy way of doing the converse, taking something
> out of one. It would be especially powerful if one could take things
> out of implicit lists, ie say 'all filenames of this pattern, except
> filenames of that pattern' conveniently.

i've always wanted this in a shell, but never found a convenient notation  
for it.  if someone can suggest one, it's certainly a potential es feature.

i just use ``ls|grep -v'' usually.


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

* a feature I wish rc had
@ 1992-11-02 22:27 Chris Siebenmann
  0 siblings, 0 replies; 7+ messages in thread
From: Chris Siebenmann @ 1992-11-02 22:27 UTC (permalink / raw)
  To: rc

 rc has convenient ways of adding things to a list, but it has
no particularly easy way of doing the converse, taking something
out of one. It would be especially powerful if one could take things
out of implicit lists, ie say 'all filenames of this pattern, except
filenames of that pattern' conveniently.

 Just today's gratuitious feature idea (well, not too gratuitious).

	- cks


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

end of thread, other threads:[~1992-11-04  1:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1992-11-03 22:32 a feature I wish rc had Paul Haahr
1992-11-03 22:43 ` Mark-Jason Dominus
  -- strict thread matches above, loose matches on Subject: below --
1992-11-03 19:53 rsalz
1992-11-03 16:10 Tom Culliton x2278
1992-11-02 22:36 Paul Haahr
1992-11-04  1:26 ` Scott Schwartz
1992-11-02 22:27 Chris Siebenmann

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