Comment 44 for bug 515386

Johnny Arthur (ubuntu-hwbqs69) wrote :

Hi,
i have the same problem with raring.
for me there seem to be at least 2 errors in the script:
in open_gnome the wrong variable is used to find the desktop file (browser instead of desktop)
and in desktop_file_to_binary() the grep command finds multiple occurences of 'Exec'. The supposed patch below only takes the first one and removes all following lines.

hence i suppose the following changes, that seem to work for me:

@@ -319,11 +319,11 @@
         unset IFS
         [ "$dir" -a -d "$dir/applications" ] || continue
         file="$dir/applications/$desktop"
         [ -r "$file" ] || continue
         # Remove any arguments (%F, %f, %U, %u, etc.).
- command="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | sed -e 's/ .*$//'`"
+ command="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -s -d= -f 2- | sed -e 's/ .*$//;2,$d'`"
         command="`which "$command"`"
         readlink -f "$command"
         return
     done
 }
@@ -510,11 +510,11 @@
 open_gnome()
 {
     local client
     local desktop
     desktop=`xdg-mime query default "x-scheme-handler/mailto"`
- client=`desktop_file_to_binary "$browser"`
+ client=`desktop_file_to_binary "$desktop"`
     echo $client | grep thunderbird > /dev/null 2>&1
     if [ $? -eq 0 ] ; then
         run_thunderbird "$client" "$1"
     fi