Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!seismo!ll-xn!ames!oliveb!jerry From: jerry@oliveb.UUCP Newsgroups: comp.unix.questions Subject: Re: why does this script... ( : and # ) Message-ID: <1494@oliveb.UUCP> Date: Sat, 20-Jun-87 00:11:50 EDT Article-I.D.: oliveb.1494 Posted: Sat Jun 20 00:11:50 1987 Date-Received: Sun, 21-Jun-87 04:48:02 EDT References: <913@rtech.UUCP> Reply-To: jerry@oliveb.UUCP (Jerry F Aguirre) Organization: Olivetti ATC; Cupertino, Ca Lines: 46 The important thing to remember when using : in sh is that it is a null command not a begin comment character. So the following gotchas apply: - The ":" must be followed by a white space or a sh metacharacter. : this is ok :>fu is also ok but will create the file fu :this is not ok because it looks for the command ":this". - The rest of the line will undergo normal filename, variable, and other metacharacter expansion. So: : Do I need this line? will fail when it tries to glob the question mark (assuming you don't have some 5 character file names that start with "line"). Also, as previously mentioned the quotes must be balanced, perentheses have special meaning, etc. - A simicolon will end it, not just the end of line. : This is ok; But this will try to execute "But" It is safest to enclose the entire line in single quotes ala: : 'this allows you to use ?()*$<>; without problems' The only problem that leaves you is figuring out why: : 'This line won't work' If you think of : as being a faster version of: /bin/echo>/dev/null arguments used but discarded You will have a lot less problems. Also interesting is that the : command always returns true so it is also a faster replacement for /bin/true. With a little work it can also replace /bin/false. Jerry Aguirre P.S. It is amazing the number of "experienced" shell programers who get confused looks when faced with a syntax like. outputfile