[Tcsh] Interactive comments for tcsh?

Jamie Landeg-Jones jamie at catflap.org
Tue Sep 26 01:10:03 UTC 2023


M G P <tateusg at hotmail.com> wrote:

> Looks like both Csh and Tcsh have # as means for introducing comments interactively. However, I can't seem to trace the code. I tried with fast mode enabled, and even reinstalled the software, and is still there. Can somebody confirm the same is true for yourself as well?

I can't see that myself:

 | 01:55 (39.0°C 1600) (17) "/tmp" jamie at catflap% echo $version 
 | tcsh 6.24.10 (Astron) 2023-04-14 (x86_64-amd-FreeBSD) options wide,nls,dl,al,kan,sm,rh,color,filec
 | 
 | 01:55 (40.0°C 1600) (18) "/tmp" jamie at catflap% 
 | 
 | 01:56 (38.0°C 1600) (18) "/tmp" jamie at catflap% # hello
 | #: Command not found.
 | 
 | *1* 01:56 (38.0°C 1600) (19) "/tmp" jamie at catflap% pwd # boo
 | usage: pwd [-L | -P]
  
> I have been using ' ;: ' to introduce comments, but the shell still tries to parse the rest of the line and if there are any quotes, semi-colons, less-thans, or greater-thans, it doesn't work properly

I've been using that format to make my history cut/pastable as a block. Fortunately, though, I control what is after the ':'. Also, it relies on the fact that another ';' allows command processing to continue on the line.

| 02:05 (39.0°C 1600) (32) "/tmp" jamie at catflap% set | grep ^history
| history (10000 : '%h   (%d %D %w) %P ' ; %R\n)
| 
| 02:05 (40.0°C 1600) (33) "/tmp" jamie at catflap% history | tail
| : '    24   (Tue 26 Sep) 02:02:27 ' ; pwd
| : '    25   (Tue 26 Sep) 02:02:30 ' ; l
| : '    26   (Tue 26 Sep) 02:04:19 ' ; h
| : '    27   (Tue 26 Sep) 02:04:28 ' ; echo $history
| : '    28   (Tue 26 Sep) 02:04:39 ' ; set | grep history
| : '    29   (Tue 26 Sep) 02:04:49 ' ; set | grep ^history
| : '    30   (Tue 26 Sep) 02:04:51 ' ; h
| : '    31   (Tue 26 Sep) 02:05:29 ' ; history | tail
| : '    32   (Tue 26 Sep) 02:05:37 ' ; set | grep ^history
| : '    33   (Tue 26 Sep) 02:05:39 ' ; history | tail

You could encase your "comment" inside single-quotes, that will help with all but a quote itself, but would admittedly be a pain.

Cheers, Jamie


More information about the Tcsh mailing list