* Re: ifs substitution, how should it work?
@ 2000-05-19 22:10 Russ Cox
0 siblings, 0 replies; 10+ messages in thread
From: Russ Cox @ 2000-05-19 22:10 UTC (permalink / raw)
To: rc, tjg
Introducing contexts where singleton lists
and strings are not identical seems a very bad idea.
Then you have to explain that in general they
are but ifs isn't; and what if save ifs away
to another variable and then restore it?
What does "x=(abc); ifs=$x" do?
If you want basename, why not use basename or sed or awk?
Russ
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: ifs substitution, how should it work?
2000-05-22 7:55 Bengt Kleberg
@ 2000-05-22 8:53 ` Tim Goodwin
0 siblings, 0 replies; 10+ messages in thread
From: Tim Goodwin @ 2000-05-22 8:53 UTC (permalink / raw)
To: rc
> i wanted
> x = asd
> and
> y = (asd)
> to mean that x and y where not identical.
No, no, no. There is just one data type in rc: a list of strings. You
might sometimes think you've got a string, but you haven't: you've got a
list with one element.
Now, when ifs is used, the list of strings that it holds is interpreted
as a set of characters. I agree with you that the documentation should
be a bit clearer on this point: the man page doesn't seem to mention
anywhere what happens when ifs is a more-than-one element list.
Tim.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: ifs substitution, how should it work?
@ 2000-05-22 7:55 Bengt Kleberg
2000-05-22 8:53 ` Tim Goodwin
0 siblings, 1 reply; 10+ messages in thread
From: Bengt Kleberg @ 2000-05-22 7:55 UTC (permalink / raw)
To: rc, rsc, tjg
> From: "Russ Cox" <rsc@plan9.bell-labs.com>
> Introducing contexts where singleton lists
> and strings are not identical seems a very bad idea.
I agree about the context bit. ie, lists and strings should be (or not be) identical in all contexts.
it is just that I thought that they should not be identical.
i wanted
x = asd
and
y = (asd)
to mean that x and y where not identical.
Best Wishes, Bengt
===============================================================
Everything aforementioned should be regarded as totally private
opinions, and nothing else. bengt@softwell.se
``His great strength is that he is uncompromising. It would make
him physically ill to think of programming in C++.''
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: ifs substitution, how should it work?
@ 2000-05-18 12:57 Bengt Kleberg
0 siblings, 0 replies; 10+ messages in thread
From: Bengt Kleberg @ 2000-05-18 12:57 UTC (permalink / raw)
To: bengt, tjg; +Cc: rc
> From: Tim Goodwin <tjg@star.le.ac.uk>
> > ; x = ``(abc) {cmd...}
> > ; echo $x => 1a2b3 4c5
> If you want awk, you know where to find it. :-)
Yes, but I had this little problem and suddenly realised that the mysterious
``(abc) {cmd...}
actually might be used for something! I have never used it before.
> I don't think anything more complicated than single character field
> seperators belongs in a shell: particularly not rc.
OK. Would you consider making ``(abc)
a parse time error? only allow ifs=asd, or ifs=( a s d ), not ifs=(asd) too.
Or, as with the confusing
if ( {} && {} ) {cmd...}
vs
if ( () && () ) {cmd...}
document it.
> What's the actual problem you're trying to solve?
split a filename into directory, filename and suffix. the suffix should be allowed to have more than 1 character.
the idea is to make the previously emailed base_name function (made by Carlo Strozzi <carlos@linux.it>)
more like the os utility basename.
Best Wishes, Bengt
===============================================================
Everything aforementioned should be regarded as totally private
opinions, and nothing else. bengt@softwell.se
``His great strength is that he is uncompromising. It would make
him physically ill to think of programming in C++.''
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: ifs substitution, how should it work?
2000-05-18 8:12 Bengt Kleberg
@ 2000-05-18 12:12 ` Tim Goodwin
0 siblings, 0 replies; 10+ messages in thread
From: Tim Goodwin @ 2000-05-18 12:12 UTC (permalink / raw)
To: Bengt Kleberg; +Cc: rc
> ; x = ``(abc) {echo -n 1a2b3abc4c5}
> ; echo $x => 1a2b3 4c5
If you want awk, you know where to find it. :-)
I don't think anything more complicated than single character field
seperators belongs in a shell: particularly not rc.
What's the actual problem you're trying to solve?
Tim.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: ifs substitution, how should it work?
@ 2000-05-18 8:12 Bengt Kleberg
2000-05-18 12:12 ` Tim Goodwin
0 siblings, 1 reply; 10+ messages in thread
From: Bengt Kleberg @ 2000-05-18 8:12 UTC (permalink / raw)
To: bengt, byron, rc, tjg
> From: Byron Rakitzis <byron@rakitzis.com>
> So,
> ifs='abc'
> and
> ifs=(a b c)
> should accomplish the same thing.
> Isn't that what you want?
No. I wanted ifs = (abc)
Ie,
; x = ``(abc) {echo -n 1a2b3abc4c5}
; echo $x => 1a2b3 4c5
This is (IMHO) better, but I presume that there is too much code out there
that depends upon ifs='abc' beeing equal to ifs=(abc).
What if I volunteered to fix everybody elses code for them (provided that they send it to me :-)
Best Wishes, Bengt
===============================================================
Everything aforementioned should be regarded as totally private
opinions, and nothing else. bengt@softwell.se
``His great strength is that he is uncompromising. It would make
him physically ill to think of programming in C++.''
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: ifs substitution, how should it work?
@ 2000-05-18 6:32 Byron Rakitzis
0 siblings, 0 replies; 10+ messages in thread
From: Byron Rakitzis @ 2000-05-18 6:32 UTC (permalink / raw)
To: bengt, rc, tjg
> From: Bengt Kleberg <bengt@softwell.se>
> Subject: Re: ifs substitution, how should it work?
>
> Re: ifs substitution, how should it work?
>
> > What would you expect
>
> > ; ifs=(' ' '<tab>' '
> '
>
> > to do (where `<tab>' represents a literal tab)?
>
>
> I had but seen code with lists as ifs arguments, and therefore thought
> that rc was using lists.
> Ie, I would have written it as:
>
> ; ifs=(' ' '<tab>' '
> ')
>
> Would it create much trouble to change rc :-)
I am not sure what the problem is...
At the moment rc scans ifs as a list and as a sequence of characters.
i.e., the implementation is as follows:
[from glom.c:bqinput]
memzero(isifs, sizeof isifs);
for (isifs['\0'] = TRUE; ifs != NULL; ifs = ifs->n)
for (s = ifs->w; *s != '\0'; s++)
isifs[*(unsigned char *)s] = TRUE;
So,
ifs='abc'
and
ifs=(a b c)
should accomplish the same thing.
Isn't that what you want?
Byron.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: ifs substitution, how should it work?
@ 2000-05-16 11:22 Bengt Kleberg
0 siblings, 0 replies; 10+ messages in thread
From: Bengt Kleberg @ 2000-05-16 11:22 UTC (permalink / raw)
To: rc, tjg
Re: ifs substitution, how should it work?
> What would you expect
> ; ifs=(' ' '<tab>' '
'
> to do (where `<tab>' represents a literal tab)?
I had but seen code with lists as ifs arguments, and therefore thought
that rc was using lists.
Ie, I would have written it as:
; ifs=(' ' '<tab>' '
')
Would it create much trouble to change rc :-)
Best Wishes, Bengt
===============================================================
Everything aforementioned should be regarded as totally private
opinions, and nothing else. bengt@softwell.se
``His great strength is that he is uncompromising. It would make
him physically ill to think of programming in C++.''
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: ifs substitution, how should it work?
2000-05-12 10:14 Bengt Kleberg
@ 2000-05-15 9:27 ` Tim Goodwin
0 siblings, 0 replies; 10+ messages in thread
From: Tim Goodwin @ 2000-05-15 9:27 UTC (permalink / raw)
To: rc
> (i have failed utterly to understand the simple rc syntax before, so
> presumably I only need a friendly explanation as to why they must be
> the same :-)
I bet you don't even need an explanation :-). What would you expect
; ifs=' <tab>
'
to do (where `<tab>' represents a literal tab)?
I don't know why Duff didn't make $ifs an rc list, but it remains
in rc as it was in Bourne: a string treated as a list of individual
characters.
Tim.
^ permalink raw reply [flat|nested] 10+ messages in thread
* ifs substitution, how should it work?
@ 2000-05-12 10:14 Bengt Kleberg
2000-05-15 9:27 ` Tim Goodwin
0 siblings, 1 reply; 10+ messages in thread
From: Bengt Kleberg @ 2000-05-12 10:14 UTC (permalink / raw)
To: rc
Greetings,
I thought that these two expression would produce different output
; x = ``( a b c ) {echo -n 1a2b3abc4}
; echo $x
1 2 3 4
and then
x = ``( abc ) {echo -n 1a2b3abc4}
; echo $x
1 2 3 4
Obviously they do not, but since I was expecting
1a2b3 4
in the last case I wonder if this similarity is 'the real thing'?
(i have failed utterly to understand the simple rc syntax before, so presumably I only need
a friendly explanation as to why they must be the same :-)
Best Wishes, Bengt
===============================================================
Everything aforementioned should be regarded as totally private
opinions, and nothing else. bengt@softwell.se
``His great strength is that he is uncompromising. It would make
him physically ill to think of programming in C++.''
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2000-05-23 23:01 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-05-19 22:10 ifs substitution, how should it work? Russ Cox
-- strict thread matches above, loose matches on Subject: below --
2000-05-22 7:55 Bengt Kleberg
2000-05-22 8:53 ` Tim Goodwin
2000-05-18 12:57 Bengt Kleberg
2000-05-18 8:12 Bengt Kleberg
2000-05-18 12:12 ` Tim Goodwin
2000-05-18 6:32 Byron Rakitzis
2000-05-16 11:22 Bengt Kleberg
2000-05-12 10:14 Bengt Kleberg
2000-05-15 9:27 ` Tim Goodwin
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).