Path: utzoo!news-server.csri.toronto.edu!rutgers!usc!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!lll-winken!elroy.jpl.nasa.gov!jarthur!dfoster From: dfoster@jarthur.Claremont.EDU (Derek R. Foster) Newsgroups: comp.unix.shell Subject: csh exit(status) Message-ID: <11074@jarthur.Claremont.EDU> Date: 5 Mar 91 00:44:38 GMT Distribution: usa Organization: Harvey Mudd College, Claremont, CA 91711 Lines: 37 Can anyone explain the following output? I looked at the csh man page under "exit" and it said that exit(stat) would terminate a shell and return exit status 'stat', where stat was an expression. However, I tried it, and received the following results ( the '%' is my prompt): % if { exit( 1 == 1 ) } echo "y" % if { exit( 1 == 0 ) } echo "y" y % if { exit( 1 != 1 ) } echo "y" y % if { exit( 0 == 0 ) } echo "y" As you can see, it appears that the opposite truth value is being returned. When the expression ( 1 == 1, etc. ) is true, the value given to the 'if' statement is false, and vice versa. This seems to be quite consistent. (It makes no difference if I run the 'exit' command in a subshell by enclosing the { } in ( ), just in case you were wondering.) Why is this happening? Is this a bug or a feature? Can anyone else reproduce these results? The reason I am trying to do this is so that I can write, in effect, user-defined functions along the lines of: alias isxxxfile 'exit ( "\!*" =~ xxx* )' if { isxxxfile $somefile } dosomething; If there is an easier way to do this, I would appreciate information on it. Mostly, however, I would like to understand why exit( ) seems to be logically inverting its operands. Any help would be greatly appreciated. Thanks! Derek Riippa Foster