You are not logged in.

#1 2011-05-16 19:28:00

jwhendy
Member
Registered: 2010-04-01
Posts: 621

xdg-open seg fault when using application default set via xdg-mime

Hi,


I use Chromium and have set xdg-mime to open .pdf files with Evince using:

]$ xdg-mime default evince.desktop application/pdf

I can verify that it's set with:

$ xdg-mime query default application/pdf
evince.desktop

When I download a pdf in Chromium and open it, it opens in Evince, but when closing Evince, it brings up Firefox as well. I thought this was solved by setting defaults via xdg-mime. I only caught the real potential issue because I used xdg-open to open a pdf directly. After I quit out of Evince, stderr spits out the following at the command line:

$ xdg-open test.pdf 
/usr/bin/xdg-open: line 396: 19916 Segmentation fault      $command_exec "$1"

This is when Firefox pops open. Quitting firefox ends the xdg-open command.

Looking at the actual file, it's complaining about this chunk:

open_generic_xdg_mime()
{
    filetype=`xdg-mime query filetype "$1" | sed "s/;.*//"`
    default=`xdg-mime query default "$filetype"`
    if [ -n "$default" ] ; then
        xdg_user_dir="$XDG_DATA_HOME"
        [ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share"

        xdg_system_dirs="$XDG_DATA_DIRS"
        [ -n "$xdg_system_dirs" ] || xdg_system_dirs=/usr/local/share/:/usr/share/

        for x in `echo "$xdg_user_dir:$xdg_system_dirs" | sed 's/:/ /g'`; do
            local file="$x/applications/$default"
            if [ -r "$file" ] ; then
                command="`grep -E "^Exec(\[[^]=]*])?=" "$file" | cut -d= -f 2- | first_word`"
                command_exec=`which $command 2>/dev/null`
                if [ -x "$command_exec" ] ; then
                    $command_exec "$1"
                    if [ $? -eq 0 ]; then
                        exit_success
                    fi
                fi
            fi
        done
    fi
}

Any suggestions on fixing this? It looks like it's specifically not happy about the ending chunk:

  $command_exec "$1"
                    if [ $? -eq 0 ]; then
                        exit_success

In emacs, the $command_exec isn't showing up color coded as a variable. Should it be something more like:

eval '$command_exec "$1"'

I don't know shell scripts very well, but I'm guessing something might be wrong with this?

Last edited by jwhendy (2011-05-16 19:29:29)

Offline

#2 2011-05-16 19:37:12

jwhendy
Member
Registered: 2010-04-01
Posts: 621

Re: xdg-open seg fault when using application default set via xdg-mime

Update: This works (line 402 in /usr/bin/xdg-open):

---( From )---

$command_exec "$1"

---( To )---

eval `"$command_exec" "$1"`

At least for me, I get the expected behavior for pdfs (evince opens the file, nothing else) with this change. Is this a bug?

Offline

Board footer

Powered by FluxBB