Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/17/84; site nbires.UUCP Path: utzoo!watmath!clyde!cbosgd!hplabs!hao!nbires!nose From: nose@nbires.UUCP (Steve Dunn) Newsgroups: net.unix-wizards,net.bugs.4bsd Subject: C-Shell weirdness Message-ID: <676@nbires.UUCP> Date: Tue, 25-Mar-86 12:40:01 EST Article-I.D.: nbires.676 Posted: Tue Mar 25 12:40:01 1986 Date-Received: Fri, 28-Mar-86 07:16:04 EST Distribution: net Organization: NBI,Inc, Boulder CO Lines: 53 Xref: watmath net.unix-wizards:17356 net.bugs.4bsd:2011 I've been foolish enough to try to write a shell script lately. I'm using the C-shell on 4.2 berkley UNIX. Since both UNIX and its documentation are for me just a bit cryptic (Ahem) I can't even be sure what's a bug and what's actually really intended to be that way, so I'm posting this to both bugs and wizards. I am interested in anyone who has solutions to or explanations for any of these problems. 1. if tests: the statement: if ($arg == '-b') echo 'UNIX is fun' Will get the error "If: missing filename" if $arg happens to equal -x or -e or any of the other constructs used to test file attributes. The statement will NOT fail if $arg happens to equal other reserved words such as "if" or "foreach". I did find a kludge to get around this but it makes be want to rip out my intestines with a fork. (Well actually its not quite *that* bad...) The statement can be replaced by this one: if (x$arg == 'x-b') echo 'UNIX is fun' Is there a better way to do this and why does this happen in the first place? 2: Count of number of words in a variable (Or when is nothing something) This: set hosed = '' echo $#hosed yields the result '1' It seems to me that a variable with null contents has ZERO words not one 3: Logical not operator According to the csh man page the logical not operator "!" is available. Unfortunately the statements (in a shell script) set lights_on = 1 if (!$lights_on) echo 'nobody home' yield the message "0: event not found". Apparently the shell is trying to do a history substitution instead of a negation. I have tried all manner of quoting to get around this - nothing works. Well then, given that "!" is used both to signal history substitutions and as a logical not operator, how can you tell which the shell will choose to do in a given situation? -Steve "If I only had a brain..." Dunn