C-shell expression bug with fix. My fix.

Rob McMahon cudcv at daisy.warwick.ac.uk
Mon Apr 4 22:52:38 AEST 1988


In article <469 at sbsvax.UUCP> greim at sbsvax.UUCP (Michael Greim) writes:
>In <479 at sol.warwick.ac.uk> Rob McMahon [me] writes :
>> [bug ...]
>> 	% if ( abc =~ * ) echo yes
>> 	<silence>
>> 	% if ( abc =~ ** ) echo yes
>> 	yes
>> [strange behaviour ...]
>> 	% if ( 2 == 2 + ) echo yes
>> 	yes
>
>Well the fix causes some new bugs.

( Are there other bugs introduced besides rejecting the missing argument ? )

>I don't think it should be an error if you tried
>	if ( 2 == 2 + ) echo yes
>because the manual explicitly says :
>	"... Null or missing arguments are considered '0'"
>so my fix only fixes the behaviour when dealing with a pattern.

Well having R'edTFM a bit better, I have to agree you're right, my fix
was wrong, and it should accept missing arguments.  (I would contend
that this is just to protect people who leave the quotes off their
variables in ( $file == "" ), and delays their script breaking until
their variable contains a metacharacter, but that's another matter.)

However the fixed fix also goes against the manual, because suddenly =~
and !~ get tightly coupled to the next argument, and ignore the
precedence rules on the right hand side.  Now, since there are no
operators that return strings, that could contain metacharacters, and I
don't suppose anyone would enclose their pattern in (), =~ could be
replaced by == in these cases, but in that case the manual entry should
be changed, and it does preclude ever adding string operators.

Note that my original fix was in two parts, to cure the two problems as
I saw them, and "unpatching" the one that changed return("") to
bferr("...") would fix "( x =~ * )" without breaking "( 2 == 2 + )" or
'set file = ""; if ( $file == "" )'.

Anybody "official" want to comment on which fix is fixed ?

>Have a nice day,
>		Michael

And seasons greetings to you too.

Rob

-- 
UUCP:   ...!mcvax!ukc!warwick!cudcv	PHONE:  +44 203 523037
JANET:  cudcv at uk.ac.warwick.cu          ARPA:   cudcv at cu.warwick.ac.uk
Rob McMahon, Computing Services, Warwick University, Coventry CV4 7AL, England



More information about the Comp.bugs.4bsd.ucb-fixes mailing list