How to enter a comment on csh?

In bashI used #to enter a comment. Even in an interactive session.

bash-3.2$ #
bash-3.2$ #
bash-3.2$ #
bash-3.2$ 

cshfor this error. How can I add a comment to an interactive session csh? In other words, I'm looking for a way to make a 100% comment on csh.

root@freebsd9:~ # #
#: Command not found.
root@freebsd9:~ # # 3e
#: Command not found.
root@freebsd9:~ # #
#: Command not found.
root@freebsd9:~ # 
+4
source share
4 answers

Interactive csh or tcsh does not make comments. The character #introduces comment only in the script. (This is not like the behavior of sh and its derivatives, such as bash.) Quoting the man page csh(from Solaris 9, one of the remaining systems, where it cshis not only a symbolic link to tcsh)

, # , . , \ .

, .

tcsh, - :, :

% : 'This is not a comment, but it acts like one.'

( % , : - ). - ; , , :

% : This will create the file "oops.txt" > oops.txt

, : - , .

: Bourne , , .

/bin/csh : , :

csh% : 'This will not work.'
:: Too many arguments
csh% 

( , , tcsh, csh.)

: csh, , , echo :

csh% echo 'This is not a comment, but it acts like one.' > /dev/null

: http://www.perl.com/doc/FMTEYEWTK/versus/csh.whynot

+4

, . echo.

#!/bin/tcsh
echo "This is comment line."
echo "But still, beware... Because `expression` is still being evaluated.

.

+1

# tcsh csh, :

alias '#' 'echo \!* >> /dev/null'

.tcshrc .cshrc, .

(, , -, , .)


Note. As Kate Thompson noted, this will still give errors if your comment includes redirection characters such as >or >>, but used in this way does not seem to create an unwanted redirection file. Separating the comment in single quotes ( ') is still a workaround.

0
source

Check if your script has UNIX EOL Format. Has some problems with Windows EOL Format.

-1
source

All Articles