Consider the following three error cases: 1. foo.bar does not exist. "xdg-mime --info foo.bar" does not print any result. Exit value is 0. We would expect an error message and non-zero exit. 2. foo.bar is a zero byte readable file. "xdg-mime --info foo.bar" prints "text/plain". Is this the expected default behavior? If so, it should be stated. 3. foo.bar is a zero byte file with permissions 000. "xdg-mime --info foo.bar" prints "application/octet-stream". We would expect an error message and non-zero exit. Environment is SUSE 10.0, Gnome 2.12.0
Behavior on KDE3.5 is 1. prints application/octet-stream 2. prints application/x-zerosize 3. prints application/x-zerosize on the file from (2) and application/octet-stream on a file with size > 0 /usr/bin/file does 1. prints error exits with error code 2. prints application/x-empty 3. prints application/x-empty for the zero sized file and an error message for a file with length. Return value is 0 in both cases.
Presently, on gentoo kde 3.5.3, I get the following: 1. Error code == 1, error msg "--info: Invalid parameter/option" 2. ditto 3. ditto Is this expected behavior?
Syntax has changed, instead of "xdg-mime --info" use "xdg-mime query filetype" 1. Now returns with 2 --> "One of the files passed on the command line did not exist." With regard to 2 and 3: There is no guarantee that results in different environments will be the same, is there a reason why the cases described should be treated as special case? That said, we can do a check for 3 and return an error code for "file not readable"
Am I doing something wrong? I get this on kde: $ ./xdg-mime query foo.bar foo.bar: Invalid parameter/option $ echo $? 1
try $ ./xdg-mime query filetype foo.bar
Okay, the original cases described seem okay: 1. $ ./xdg-mime query filetype foo.bar Error: You must specify an existing file. 2. $ touch foo.bar $ ./xdg-mime query filetype foo.bar application/x-zerosize 3. # chmod 000 foo.bar $ ./xdg-mime query filetype foo.bar application/x-zerosize However, according to the man page, xdg-mime also supports a 'default' parameter, and this seems to be misbehaving: $ rm foo.bar $ ./xdg-mime query default foo.bar Error: You must specify an existing file. $ touch foo.bar $ ./xdg-mime query default foo.bar basename: missing operand Try `basename --help' for more information. $ file foo.bar foo.bar: empty But it seems okay with valid file content: $ echo 'hello world' > foo.bar $ file foo.bar $ ./xdg-mime query default foo.bar kwrite.desktop $ file foo.bar foo.bar: ASCII text
(In reply to comment #3) > With regard to 2 and 3: There is no guarantee that results in different > environments will be the same, is there a reason why the cases described > should be treated as special case? It seems to me that the whole point is to have consistant well defined behavior across distributions, otherwise applications may count on one behavior but find another. However, perhaps I have highlighted some exceptional cases here that should be documented as such. My goal was not to treat thease cases as special, but just call attention to what I thougt was a normal case that was not working properly.
The case below has been fixed in CVS for Beta1 (at least with KDE) $ touch foo.bar $ ./xdg-mime query default foo.bar basename: missing operand Try `basename --help' for more information.
Proposed resolution: 1. (fixed already) 2. WONTFIX 3. Provide custom error message if file is not readable.
Created attachment 6382 [details] [review] File check functions Possible extension to xdg-utils-common.in for checking the availability/permissions on input and output files
Created attachment 6383 [details] [review] Improved patch There is already an exit_failure function for missing files, using that instead
Created attachment 6384 [details] [review] Using check_input_file in xdg-mime
Looks good, please commit.
Committed the two input files, but left the resulting file untouched since my xmlto breaks the description text. Probably some locale setting problem
Thanks, will regenerate file.
Final resolution 1. FIXED 2. WONTFIX 3. FIXED
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.