Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!uunet!pilchuck!ssc!fyl From: fyl@ssc.UUCP (Phil Hughes) Newsgroups: comp.unix.xenix.sco Subject: Re: emptying a file and keeping its ownership Message-ID: <744@ssc.UUCP> Date: 7 Jan 91 22:19:23 GMT References: <1990Dec30.220722.29050@jarvis.csri.toronto.edu> <97@gdx.UUCP> Distribution: na Organization: SSC, Inc., Seattle, WA Lines: 39 In article <97@gdx.UUCP>, jay@gdx.UUCP (Jay A. Snyder) writes: > > > >I find that in my csh, the following works: > > % : > file > >That initial colon does the trick. What mechanism is operating here? > The ':' is a comment character for old versions of sh (dating from > V7), in fact V7 bourne shell doesn't accept '#' for comments. Most > modern verions of sh do recongnize the ':'. > If you are running Xenix, the ':' is also used to tell a non bourne > shell that a script is intended for bourne shell (equiv to a BSD file > with #!/bin/sh as the first line). Well, close. The : command is a null command. It returns 0 exit status. Sort of like true and, in fact, I expect it predates true. But, it isn't a comment. This is why the proposed command works. There is a command but the only thing it does is return a 0 exit status. Comments were added later and # is the comment character. Prior to the existence of #, people would use : to introduce a comment, the most common one being the program name on the first line of a script. When C shell was born, there needed to be a way to tell it whether it was to interpret a script itself or pass it off to the Bourne shell. As many Bourne shell scripts already existed a method was needed that would not break existing scripts. So the # comment was born and it is required to be the first character of a C shell script. If it is not (as would be the case will all existing Bourne shell scripts) it would be passed off to the Bourne shell. The reason a line with just > file works in Bourne shell is the shell performs all the I/O redirection and then looks for the command. There is none so it just terminates and is happy. C shell apparently cares. -- Phil Hughes, SSC, Inc. P.O. Box 55549, Seattle, WA 98155 (206)FOR-UNIX uunet!pilchuck!ssc!fyl or attmail!ssc!fyl (206)527-3385