greim@sbsvax.UUCP (Michael Greim) (04/12/88)
In <512@sol.warwick.ac.uk> Rob McMahon writes =In article <469@sbsvax.UUCP> greim@sbsvax.UUCP (Michael Greim) writes: =>In <479@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 just cannot remember, and of course I removed the seashell with Rob's fix as soon as mine was finished. = =>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.) = People should be careful about such things (it got me too from time to time :-) =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. As 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. [...] It is true, that the next word after the =~ is considered to be a pattern. I just discovered, that "if ( $a =~ $b * 4 )" produces a syntax error, although it should be correct according to the manual. Did Rob's fix evaluate this correctly? Well, I think we both have trouble here with interpreting the real meaning of the terse manual section. A syntax diagram would be quite useful and valuable, is there any ? Or should we hold a vote ? Or what ? Do we really have to rewrite this section of the csh ? Or just the manual ? I will look into it a little closer if I have time. Michael -- +------------------------------------------------------------------------------+ | UUCP: ...!uunet!unido!sbsvax!greim | Michael T. Greim | | or greim@sbsvax.UUCP | Universitaet des Saarlandes | | CSNET: greim%sbsvax.uucp@Germany.CSnet| FB 10 - Informatik (Dept. of CS) | | ARPA: greim%sbsvax.uucp@uunet.UU.NET | Bau 36, Im Stadtwald 15 | | Phone: +49 681 302 2434 | D-6600 Saarbruecken 11, West Germany | +------------------------------------------------------------------------------+ | Watch this space. Don't let it escape. | +------------------------------------------------------------------------------+