I am using csh script and I want to see the line numbers when executing csh script in debug mode. I am doing like
csh -x script_name
What do I have to do apart from this to see line numbers in debug mode?
I am using csh script and I want to see the line numbers when executing csh script in debug mode. I am doing like
csh -x script_name
What do I have to do apart from this to see line numbers in debug mode?
There is no built-in feature to do this. The only method I can think of is (ab)using the
postcmd
special alias. This alias will be run after every command:Outputs:
Unfortunately, this will clutter the
-x
output:Which we can sort of filter with
grep
:All of this is less than perfect, and may not even work very well with large scripts...
As you've asked a number of
csh
related questions for the last few days:While
tcsh
can work fine as an interactive shell,tcsh
orcsh
is generally not well suited for scripting tasks. There are many things missing, incomplete, or simply behave in a "strange" way. It's even more ugly than normal shell scripting with POSIX (and that's saying a lot).Unless you have a good reason not to (such as maintaining existing scripts), you probably should give up on
csh
for now, and go with either a "real" programming language (Python, Ruby, Perl, whatever), or use/bin/sh
,bash
, orzsh
.