Sep 2, 2017

Bash: enabling Eclipse for Bash Programming | Plugin basheclipse (debugging) part 2

If you want to debug bash scripts inside eclipse you have to do 2 things:
BUT:
As i wrote in the last posting, toggling breakpoints was neither possible in Eclipse Neon  nor Eclipse Juno.

First you have to install JDK 1.6 and Eclipse Luna to be able to set breakpoints. (see EDIT at the end of the posting: Neon works as well...)




After you have to set up

  • Eclipse Luna with JDK 1.6
  • installad shelled & basheclipse
    (and follow the steps from posting shelled and posting basheclipse)
you have to create a Shell Script project within a shell Shell Script file:

via ->new->other


and again ->new->other

Choose the bash script you want to debug:

After that put some content into your shell.sh file:
(as written in the basheclipse posting, you have to add _DEBUG.sh into your project directory where shell.sh resides and add this line at the beginning of your shell.sh:
. _DEBUG.sh
Then change to the debug perspective and go to run-> debug configurations


 and then start a debugging session:
->run->debug

Then you will get the following:

Hmmm...
?
It says, it is running and not waiting at the first breakpoint...
What is wrong here?

Just keep calm. You have to start your shell.sh:
bash ./shell.sh

And here we go:


As you can see, the variable "a" is show with its value "test" and you can walk through your script breakpoint by breakpoint....

I asked the developer at sourceforge, why it does not work with Eclipse Neon. I hope i will get an answer... (or better a fix ;-)

EDIT: After some retries: switching from OpenJDK to Oracle's JDK did the job. (The installation of basheclipse has to be done with Oracle's JDK. After that i was able to run it on Eclipse Neon even with OpenJDK).

EDIT2: It is even possible to debug bash scripts on a remote host.

No comments:

Post a Comment