2

I am trying to make the xdebug stack links to open files directly in netbeans, here is what I have done so far:

  1. I created an executable file /home/david/bin/netbeans.sh (which I chmoded +x) containing:

    #!/bin/bash
    

    url=$2 file=${url#//} file=${file%?line=} line=${url#*line=}

    /home/david/Programs/netbeans-8.1/bin/netbeans --open $file:$line

  2. in /etc/php5/apache2/php.ini I added

    xdebug.file_link_format = "netbeans://%f?line:%l"
    
  3. in firebug "about:config" I created a new boolean:

    network.protocol-handler.expose.netbeans => false
    
  4. I created a new url-handler in Gnome's gconf:

    gconftool-2 -t string --set /desktop/gnome/url-handlers/netbeans/command "/home/david/bin/netbeans.sh %s"
    gconftool-2 -t bool --set /desktop/gnome/url-handlers/netbeans/enabled true
    gconftool-2 -t bool --set /desktop/gnome/url-handlers/netbeans/needs_terminal false
    

now when I get an error, the files of xdebug's stack are links of type netbeans:///var/www/html/path/to/file.php, all good.
When I click on one of those links, I get the "Launch Application" window where I have to choose the application to open the file with: I select the executable I created in step 1, i.e.: /home/david/bin/netbeans.sh but I get an error message saying:

/home/david/: does not exist, or is not a plain file

And this is where I am stuck, I don't understand why I get this error and how to solve it.

edit screenshot of gnome config enter image description here

OSdave
  • 378

1 Answers1

1

Okay, so we found the solution for this problem. First of all there was a wrong argument number if the netbeans.sh file. So url=$2 should be url=$1. But also the parsing of the filename and the line number in the script was wrong.

Since the provided string has the form netbeans:///path/to/file?line=[LineNumber] the parsing can be done by:

#!/bin/bash

# extract the protocol
proto="$(echo $1 | grep :// | sed -e's,^\(.*://\).*,\1,g')"
# remove the protocol
url="$(echo ${1/$proto/})"
# get file and line
file="$(echo $url | cut -d\? -f1)" 
line="$(echo $url | cut -d\= -f2)"

/home/david/Programs/netbeans-8.1/bin/netbeans --open $file:$line