I was wondering if there is an IDE that would allow me to define an ssh connection to a remote host, connect, and locally debug a script running remotely (kind of like you can debug a remote Java app in Eclipse)? I want to be able to go line by like and examine vars and all that.

2 Answers 2


An easy way to improve the tracing output is the following code fragment:

  PS4='[${BASH_SOURCE[0]:-inherited}:${LINENO}:${FUNCNAME[0]:-main}] '
  set -o xtrace

This will show you:

  1. source file
  2. source line number
  3. function name

see also wiki page for c42-common-functions

Output example:

   $ c42_loglevel_trace
   $ pidkill --help
   ++ '[' '+ ' == '+ ' ']'
   ++ PS4='[${BASH_SOURCE[0]:-inherited}:${LINENO}:${FUNCNAME[0]:-main}] '
   [/usr/local/bin/pidkill:224:main] '[' 1 -eq 0 ']'
   [/usr/local/bin/pidkill:230:main] signal=KILL
   [/usr/local/bin/pidkill:231:main] '[' 1 -gt 0 ']'
   [/usr/local/bin/pidkill:233:main] case $1 in
   [/usr/local/bin/pidkill:268:main] shift 1
   [/usr/local/bin/pidkill:269:main] help
   [/usr/local/bin/pidkill:57:help] cat
   pidkill <-h|--help>                                              this help
   [/usr/local/bin/pidkill:70:help] copyLeft
   [/usr/local/bin/pidkill:13:copyLeft] echo ''

An alternative is bashdb:

This is a complete rewrite of the Korn Shell debugger from Bill Rosenblatt's `Learning the Korn Shell', published by O'Reilly and Associates (ISBN 1-56592-054-6) with changes by Michael Loukides and Cigy Cyriac. However, this code now depends on a number of debugging support features that are neither part of the POSIX standard nor present are in many POSIX-like shells. Although you can just use bashdb to debug scripts written in BASH, it can also be used just as a front-end for learning more about programming in BASH. As an additional aid, the debugger can be used within the context of an existing script with its functions and variables that have already been initialized; fragments of the existing code can be experimented with by changing them inside the debugger.


an IDE for debugging bash scripts? I don't see how a graphical GUI would help to ssh into a host and present you a cli output of a script. Also I don't know of a bash debugger you can run script inside of. but you are not specifying which kind of shell script you are talking about.

if it is bash, then you can use the -x flag to enable tracing. which is almost debugging. but you can't break and step in/out/over ... I find it very useful though.

so you can enable it straight on the shebang with

#!/usr/bin/bash -x

or use set to enable/disable tracing

set -x # enable debugging

set +x # disable tracing

you can also pause your script with read

ENV vars can be found in /proc/<PID>/environ they are \0 separated, you can use sed to replace the null char with a CR

cat /proc/10815/environ | sed 's/\0/\n/g'


forget GUI for making your life easier. GUI is for users and consumers.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .