RHN System ID: Customer Contact Name: Kazuhiro Kikuchi Description of Problem: We tested the "tcsh". We made the following script in tcsh, and then execute it. [script] #!/bin/tcsh @ i = 5 * 2 % 3 @ j = 2 % 3 * 5 @ k = 5 * 4 % 3 * 2 @ l = 5 * 4 / 2 * 2 echo "5 * 2 % 3 = $i" echo "2 % 3 * 5 = $j" echo "5 * 4 % 3 * 2= $k" echo "5 * 4 / 2 * 2= $l" [result] # ./test.sh 5 * 2 % 3 = 10 2 % 3 * 5 = 2 5 * 4 % 3 * 2= 20 5 * 4 / 2 * 2= 5 The operator is being written on the man page as follows. [tcsh man page] These operators are similar to those of C and have the same precedence. They include || && | ^ & == != =~ !~ <= >= < > << >> + - * / % ! ~ ( ) Here the precedence increases to the right, '==' '!=' '=~' and '!~', '<=' '>=' '<' and '>', '<<' and '>>', '+' and '-', '*' '/' and '%' being, in groups, at the same level. The C program calculates the operators which have same level from the left operator. However, this issue is different from the result of the calculation from the left operator. It seems that "%", "/" and "*" of tcsh are calculated from the right operator. Which is correct, man page or the actual result? Version-Release number of selected component: Red Hat Enterprise Linux Server release 5.1 (Tikanga) Architecture: ia64 Kernel Version: kernel-2.6.18-53.el5 tcsh-6.14-12.el5 Drivers or hardware or architecture dependency: None. How reproducible: Always Step to Reproduce: Make the script in tcsh, and then execute it. [script] #!/bin/tcsh @ i = 5 * 2 % 3 @ j = 2 % 3 * 5 @ k = 5 * 4 % 3 * 2 @ l = 5 * 4 / 2 * 2 echo "5 * 2 % 3 = $i" echo "2 % 3 * 5 = $j" echo "5 * 4 % 3 * 2= $k" echo "5 * 4 / 2 * 2= $l" [result] # ./test.sh 5 * 2 % 3 = 10 2 % 3 * 5 = 2 5 * 4 % 3 * 2= 20 5 * 4 / 2 * 2= 5 Actual Results: Description in man page is different from actual operation. Expected Results: Description in man page is same with actual operation. Summary of actions taken to resolve issue: manpage patch provided to clarify the issue --- tcsh-6.14.00/tcsh.man.original 2008-04-15 18:27:14.000000000 +0900 +++ tcsh-6.14.00/tcsh.man 2008-04-15 18:28:01.000000000 +0900 @@ -1602,7 +1602,9 @@ .PP Here the precedence increases to the right, `==' `!=' `=~' and `!~', `<=' `>=' `<' and `>', `<<' and `>>', `+' and `\-', `*' `/' and `%' being, in -groups, at the same level. The `==' `!=' `=~' and `!~' operators compare +groups, at the same level. When multiple operators which have same precedence +are used in one expression, calculation must be done from operator of right +side. The `==' `!=' `=~' and `!~' operators compare their arguments as strings; all others operate on numbers. The operators `=~' and `!~' are like `!=' and `==' except that the right hand side is a glob-pattern (see \fBFilename substitution\fR) against which the left hand Location of diagnostic data: None. Hardware configuration: Model: Fujitsu PRIMEQUEST 580 CPU Info: Intel(R) Itanium(R)2 Processor 1.60GHz Memory Info: Memory: 4GB Business Impact: If customer make calculation in tcsh, the expected calculation results may not be obtained. Additional Info:
Created attachment 302451 [details] tcsh-6.14.00-manfix.patch
Hi, Actually, man page is wrong, operation result is right. Two operators with same precedence are evaluated from right to left in tcsh. For more info, see: http://mx.gw.com/pipermail/tcsh-bugs/2007-August/000520.html Still same behavior in latest upstream (6.15.00), so I think it's fine to apply your patch.
This request was evaluated by Red Hat Product Management for inclusion in a Red Hat Enterprise Linux maintenance release. Product Management has requested further review of this request by Red Hat Engineering, for potential inclusion in a Red Hat Enterprise Linux Update release for currently deployed products. This request is not yet committed for inclusion in an Update release.
An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on therefore solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHBA-2009-0060.html