How to debug csh scripts?

26,469

Solution 1

This page lists two useful csh switches: -v to show each command before variables are substituted, and -x to show them afterwards.

Solution 2

In addition to -v and -x, you can stop execution for an arbitrary amount of time in csh by assigning $< to a variable that you aren't using

set unused_var = $<

This will block until you've read a line from /dev/tty, so it works even if your script is in a pipeline.

This gives you the ability to run commands and "look around" before the script is done executing.

Share:
26,469

Related videos on Youtube

Cassie
Author by

Cassie

Updated on September 18, 2022

Comments

  • Cassie
    Cassie over 1 year

    My lab uses csh scripts to run jobs. It is usually difficult for me to debug a shell script, so I'm wondering if there is a csh debugger I can use.

    I know there are some flags like -x or -v that can help, but because the script is kind of long, it would be better if I can set breakpoints on it. As I searched online, I found there is a debugger specifically for bash scripts that supports breakpoints, but I couldn't find one for csh scripts. Will the bash debugger work? Is there a csh-specific debugger I can use?

    • Bobby
      Bobby over 11 years
      Doesn't csh -x yourScript.sh cut it?
    • daisy
      daisy over 11 years
      I dont think "shell" has debugger, just echo the values out or use -x
  • Renan
    Renan over 11 years
    Welcome to Unix and Linux! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.