# comment character (special casing inputs)

Arnold Robbins arnold at gatech.CSNET
Sat Jun 29 02:59:05 AEST 1985


In article <764 at kuling> andersa at kuling.UUCP (Anders Andersson) writes:
> In article <291 at ucdavis.UUCP> ccrrick at ucdavis.UUCP (Rick Heli) writes:
> >Can anyone tell me why the # character is a comment in INTERACTIVE
> >mode in the shell?  I mean, who goes around making comments that
> >will never be seen again while running the shell in interactive
> >mode?
> 
> Well, what function should # have in interactive mode then?
> No function is also a kind of function. The idea is that things should
> work the same regardless of mode -- imagine the problems if commands,
> syntax etc. didn't behave the same when run from a file rather than
> being typed in interactively. The consequent behaviour makes both
> learning and debugging easy. Giving # a special "interactive" function
> would merely increase documentation size and human brain load, instead
> of functionality...

There is a major exception to this --- command history.  The csh follows
the above philosophy, and will actually try to do history evaluations inside
shell files. This can bite you badly.  Suppose you have a file with e-mail
addresses:

site1!persona	site2!personb

The csh command in a shell file

	Mail `cat destinations`

will cause the csh to try and do a history evaluation (and promptly bomb).
(Yes, If you say site1\!persona, it'll work, but that isn't the point.)
The above example actually happened to me.

In the history mechanism for /bin/sh I posted a couple of weeks ago, I
explicitly turn history off inside a shell file, which is how (I think) it
should be. [Note, I am not disagreeing with the overall philosophy of not
treating different inputs specially, just pointing out that there are
exceptions.]
-- 
Arnold Robbins
CSNET:	arnold at gatech	ARPA:	arnold%gatech.csnet at csnet-relay.arpa
UUCP:	{ akgua, allegra, hplabs, ihnp4, seismo, ut-sally }!gatech!arnold

Hello. You have reached the Coalition to Eliminate Answering Machines.
Unfortunately, no one can come to the phone right now....



More information about the Comp.unix mailing list