ccrrick@ucdavis.UUCP (Rick Heli) (06/20/85)
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? -- --rick heli (... ucbvax!ucdavis!groucho!ccrrick)
west@sdcsla.UUCP (Larry West) (06/21/85)
In article <291@ucdavis.UUCP> ccrrick@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? >-- > --rick heli This is true of "sh", but not "csh". I don't know what the reason is, but it is useful when doing "script" (a Berkeley program which records every character that passes through your tty -- very very useful for giving example sessions, or proof of bugs). I wish I could make "csh" treat '#' as comment-leader. -- Larry West Institute for Cognitive Science (USA+619-)452-6220 UC San Diego (mailcode C-015) [x6220] ARPA: <west@nprdc.ARPA> La Jolla, CA 92093 U.S.A. UUCP: {ucbvax,sdcrdcf,decvax,ihnp4}!sdcsvax!sdcsla!west OR ulysses!sdcsla!west
ggc@myriasb.UUCP (Gilles Chartrand) (06/23/85)
> 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? I think the general design of both csh and sh is that they work the same way reguardless of where the input is comming from (a file or a terminal). In UN*X, by the way, a terminal is a "special" file. That way a user doesn't have to learn to sets of conflicting rules. Gilles ...!alberta!myrias!ggc
andersa@kuling.UUCP (Anders Andersson) (06/25/85)
In article <291@ucdavis.UUCP> ccrrick@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...
adam@npois.UUCP (Adam V. Reed) (06/25/85)
Being able to insert a comment in interactive mode may be useful for demonstrations, instruction, and any other context in which interactive hard-copy output is saved for later reference. Adam ihnp4!npois!adam
avi@pegasus.UUCP (Avi E. Gross) (06/27/85)
In article <291@ucdavis.UUCP> ccrrick@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? Why should it mean anything else in interactive mode? I often create complicated commands I would like to execute later and put a '#' at the beginning. Then, when I am ready to run it (often after another process has completed running in the background or another window), I use the nifty Korn shell commands to return to that line, strip the '#' and actually run it. Similarly, I sometimes enter an in-line function, with some lines commented out and run it. After checkking to see that it does the right things, I edit it and remove the '#'s. A better question is why the '#' character was used as a comment character when the typical UNIX*TM Operating System came with '#' as the default character-delete character? -- -=> Avi E. Gross @ AT&T Information Systems Laboratories (201) 576-6241 suggested paths: [ihnp4, allegra, cbosg, ahuta, ...]!pegasus!avi
arnold@gatech.CSNET (Arnold Robbins) (06/28/85)
In article <764@kuling> andersa@kuling.UUCP (Anders Andersson) writes: > In article <291@ucdavis.UUCP> ccrrick@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@gatech ARPA: arnold%gatech.csnet@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....
ccrrick@ucdavis.UUCP (Rick Heli) (07/13/85)
Well, I certainly received many interesting answers to my question about why the # is a comment in the interactive mode in the shell. Thank you. A few thoughts on the responses: One person said he uses it in connection with the history mechanism. Well, the Bourne shell has no history mechanism, so his answer is only useful to Korn shell users and those who've hacked shell. Another person said that the shell makes no distinction between interactive and non-interactive mode. But on the other hand, the # is a comment in C shell scripts, but not in C shell interactive mode. This makes me doubt that shell makes no distinction. Finally, someone else asked what kind of special function I would like to give to the # character. Actually, there is none. I would like it to be a regular member of the character set for use in marking certain kinds of files. I frankly don't see why I should need a comment in interactive mode and besides I could use ":" if I wanted to use it inside script or something. -- ----- "Rescue your DNPC from a horrifying menace today!" ----- --rick heli (... ucbvax!ucdavis!groucho!ccrrick)