gvfs-open exit code is 0 when file is not found and no default application is registred

Bug #816804 reported by MestreLion
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gvfs
Fix Released
Medium
gvfs (Ubuntu)
Fix Released
Low
Unassigned

Bug Description

gvfs-open exits with error code 0 (success) even when there is error.

The following conditions should exit with error code > 0:
- File is not found
- File is found, but default application for opening it is not registred

Examples:
$ gvfs-open nofile.txt || echo "NOT FOUND!"
gvfs-open: file:///home/rodrigo/nofile.txt: error opening location: Error stating file '/home/rodrigo/nofile.txt': No such file or directory

$ touch test.mdb ; gvfs-open nofile.txt || echo "NO ASSOCIATION!" ; rm test.mdb
gvfs-open: file:///home/rodrigo/nofile.txt: error opening location: Error stating file '/home/rodrigo/nofile.txt': No such file or directory

In both situations exit code was 0, meaning success, even when gvfs-open was clearly NOT successful. This makes gvfs-open hard to use in scripts.

And the problem is even worse considering gvfs-open is used by xdg-open

A quick look at source code shows that it has a hardcoded "return 0" in main() function. The open() function is "static void". Both could easily be changed so open would be "static int open(...)", set a proper return code, and main would test for it.

Using Maverick 10.10 64bits, gvfs 1.6.4-0ubuntu1.1

Tags: patch
Revision history for this message
MestreLion (mestrelion) wrote :

Question: if this patch gets approved and merged upstream, what should i do to make it cherry-picked all the way to Maverick ?

Changed in gvfs:
importance: Unknown → Medium
status: Unknown → New
Revision history for this message
Sebastien Bacher (seb128) wrote :

Thank you for your work there

Changed in gvfs (Ubuntu):
importance: Undecided → Low
status: New → Triaged
Revision history for this message
Sebastien Bacher (seb128) wrote :

To reply to your question it's not likely that will be a candidate for stable updates, see the criterious on https://wiki.ubuntu.com/StableReleaseUpdates

Revision history for this message
MestreLion (mestrelion) wrote :

Updated patch, with cosmetic changes (spacing, line breaks, commit message)

tags: added: patch
Changed in gvfs:
status: New → Fix Released
Revision history for this message
Sebastien Bacher (seb128) wrote :

the fix has been commited to the upstream git and will be in the next update

Changed in gvfs (Ubuntu):
status: Triaged → Fix Committed
Revision history for this message
MestreLion (mestrelion) wrote :

Any chance this can be cherry-picked to maverick backports or updates?

Revision history for this message
Martin Pitt (pitti) wrote :

This was fixed in 1.9.4.

Changed in gvfs (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.