csh 에서 계산한 아주 단순한 사칙연산 결과가 이상해요

foruses의 이미지

아래처럼 10 빼기 2 빼기 8 하면 0 이 될 것을 기대했으나, 16이 나오네요.
OS가 수세리눅스인 경우 예상한대로 0이 나왔는데, 우분투에서는 16으로......어떤 차이인가요?
OS? 아님 플랫폼? 아님 csh 버전?

#!/bin/csh
set echo

set a = 10
set b = 2
set c = 8

@ x = ${a} - ${b} - ${c}

echo ${x}

익명 사용자의 이미지

c-shell의 연산순서(결합법칙)때문 입니다.
https://en.wikipedia.org/wiki/C_shell#Expressions

최근에 tcsh에서 수정되었다고 하네요

That was fixed in tcsh (6.15.01), and you can run set compat_expr to get back to the older behaviour there.

익명 사용자의 이미지

c-shell의 연산순서(결합법칙)때문 입니다.
https://en.wikipedia.org/wiki/C_shell#Expressions

최근에 tcsh에서 수정되었다고 하네요

That was fixed in tcsh (6.15.01), and you can run set compat_expr to get back to the older behaviour there.