Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 beta 4/12/84; site rlgvax.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxl!houxm!houxz!vax135!cornell!uw-beaver!tektronix!hplabs!hao!seismo!rlgvax!guy From: guy@rlgvax.UUCP (Guy Harris) Newsgroups: net.unix-wizards Subject: Re: /bin/sh feature? Message-ID: <2087@rlgvax.UUCP> Date: Mon, 9-Jul-84 21:55:31 EDT Article-I.D.: rlgvax.2087 Posted: Mon Jul 9 21:55:31 1984 Date-Received: Thu, 12-Jul-84 04:12:42 EDT References: <274@uvm-cs.UUCP> <49@pixutl.UUCP> Organization: CCI Office Systems Group, Reston, VA Lines: 38 > The problem is that sh parses comment lines starting with a ":" (don't > ask me why...) and waits for the closing "'". The reason is simple - a line starting with a ":" isn't a comment in the sense that most programming languages use the word "comment". ":" is a built-in command in the shell that does nothing. Think of it as equivalent to "echo >/dev/null 2>&1". It returns an "exit status" of 0 (true). As such, it's useful when doing "while true" (since it's built-in, it's faster than "true" which is a shell file) and useful when you want something like if ! cmp -s $1 $2 then diff $1 $2 fi which compares two files and, if unequal, "diff"s them. Unfortunately, you can't negate the exit status of a "list" in an "if", so you have to do something like if cmp -s $1 $2 then : else diff $1 $2 fi (Yes, I know you could run the "cmp" and then do a if test $? -ne 0 but that's *UG*ly.) Fortunately, every Bourne shell except the V7 shell supports *real* comments, done with "#". Everything following the "#" on the line is ignored, even by the shell's lexical analyzer. Guy Harris {seismo,ihnp4,allegra}!rlgvax!guy