rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
* thoughts on ifs
@ 1991-07-08 13:41 Arnold Robbins
  1991-07-08 14:36 ` John Mackin
  1991-07-16 12:46 ` Dave Mason
  0 siblings, 2 replies; 4+ messages in thread
From: Arnold Robbins @ 1991-07-08 13:41 UTC (permalink / raw)
  To: rc

This may be a dead issue, but it seems to me the best way to handle
the multiple separators means multiple fields problem is as follows.
If ifs is a single character, then multiple successive occurrences of
that character delineate separate fields.  If ifs is more than one
character, then fields are separated by runs of any of those characters.
This gets all the common cases

        ifs=(:)
        do something with /etc/passwd

and

        ifs = (' ' '    ' '
')
        get input from the user

Arnold


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

* Re: thoughts on ifs
  1991-07-08 13:41 thoughts on ifs Arnold Robbins
@ 1991-07-08 14:36 ` John Mackin
  1991-07-16 12:46 ` Dave Mason
  1 sibling, 0 replies; 4+ messages in thread
From: John Mackin @ 1991-07-08 14:36 UTC (permalink / raw)
  To: The rc Mailing List

    From: arnold@audiofax.com (Arnold Robbins)
    Date: Mon, 8 Jul 1991 08:41:56 -0500

    This may be a dead issue, but it seems to me the best way to handle
    the multiple separators means multiple fields problem is as
    follows.  If ifs is a single character, then multiple successive
    occurrences of that character delineate separate fields.  If ifs is
    more than one character, then fields are separated by runs of any
    of those characters.

Well, I certainly hope it is a dead issue, since in my view the 1.1beta
behaviour is correct and this suggestion should not be adopted.  My
counter-argument to this proposal is that it is not at all unusual
to want to set ifs to just newline and have it do what it does in 1.1beta.
This suggestion would break that.

    This gets all the common cases

            ifs=(:)
            do something with /etc/passwd

We keep hearing about this.  OK.  I want to know.  Hands up, all those
who _really, truly and no fooling_ have _actually_ wanted to split up
/etc/passwd in the shell.  Right.... I thought so.  All this /etc/passwd
stuff is a strawman; it's a nonsense.  It's a mere theoretical proposition
with no practical usability.

Steve Bourne got the way IFS worked _right_.  Tom Duff followed that.
These are by no means sacred cows; on the other hand, they ought to be
kept in mind.

`ifs creating null strings?  Just say No.'  See, even Nancy understands
this.

OK,
John.


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

* RE: thoughts on ifs
  1991-07-08 13:41 thoughts on ifs Arnold Robbins
  1991-07-08 14:36 ` John Mackin
@ 1991-07-16 12:46 ` Dave Mason
  1 sibling, 0 replies; 4+ messages in thread
From: Dave Mason @ 1991-07-16 12:46 UTC (permalink / raw)
  To: rc

> This may be a dead issue, but it seems to me the best way to handle
> the multiple separators means multiple fields problem is as follows.
> If ifs is a single character, then multiple successive occurrences of
> that character delineate separate fields.  If ifs is more than one
> character, then fields are separated by runs of any of those characters.

There are some problems with this, but how about if ifs is a list (the
default) then it will remove leading, trailing and repeated occurences.  If
it is a single string, then all occurrences are significant:

; x= ``: {echo ::a:b.:c::}
; whatis x
x=('' '' a b. c '' '
')

; x= ``(: .) {echo ::a:b.:c::}
; whatis x
x=(a b c)

; x= ``(: '') {echo ::a:b.:c::}
; whatis x
x=(a b. c)

This seems to handle all the useful cases in the obvious ways and allow the
special case (the third one) where required.

	../Dave


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

* Re: thoughts on ifs
@ 1991-07-08 16:52 Paul Haahr
  0 siblings, 0 replies; 4+ messages in thread
From: Paul Haahr @ 1991-07-08 16:52 UTC (permalink / raw)
  To: Arnold Robbins; +Cc: rc

> This may be a dead issue, but it seems to me the best way to handle
> the multiple separators means multiple fields problem is as follows.
> If ifs is a single character, then multiple successive occurrences of
> that character delineate separate fields.  If ifs is more than one
> character, then fields are separated by runs of any of those characters.

i think this is wrong.  don't overload the semantics of multiple list  
elements with kleene-closure.  what do the two have to do with each other?  
why is one relevant to the other?  i just don't follow.  besides, it  
doesn't handle one very important case:  where ifs is one character  
(typically newline) and you want multiple separators to be treated as one.

i originally proposed rc's old semantics because it is possible to  
synthesize the new ones from the old ones (run down a list and remove all  
empty elements.)  that seemed fine in theory, but in practice it was  
almost always wrong.  the current implementation feels much more correct,  
and if we need a new operator for ` w/o closure, then let's add that, but  
don't hack something to be non-intuitive.

besides, if you want the type of field splitting that rc used to support  
(and my impression is that it is rare in a shell that you do want it) awk  
and (shudder) perl are well suited to that.


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

end of thread, other threads:[~1991-07-16 12:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1991-07-08 13:41 thoughts on ifs Arnold Robbins
1991-07-08 14:36 ` John Mackin
1991-07-16 12:46 ` Dave Mason
1991-07-08 16:52 Paul Haahr

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