Summary: | sys-apps/file-5.0{3,4} returns success on error | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Evert <evert.gentoo> |
Component: | [OLD] Core system | Assignee: | Gentoo Linux bug wranglers <bug-wranglers> |
Status: | VERIFIED INVALID | ||
Severity: | minor | CC: | jer |
Priority: | Normal | ||
Version: | unspecified | ||
Hardware: | x86 | ||
OS: | Linux | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- |
Description
Evert
2010-10-07 08:23:06 UTC
What if you want two files examined: $ file metadata.xml foobar; echo $? metadata.xml: XML document text foobar: cannot open `foobar' (No such file or directory) 0 $ Since apparently file was designed this way, it's not a Gentoo bug. Most shells have their own means to figure out whether a file exists, so this is rather easy to work around. What about: $ cat no-file && echo OK || echo NOK cat: no-file: No such file or directory NOK $ file no-file && echo OK || echo NOK no-file: cannot open `no-file' (No such file or directory) OK I agree, it's not gentoo's fault, it's a developers bug. I'm not sure why you say "works for me"... Jeroen, can you please tell me, if "No such file or directory" is not an error, what would be an error? And of course there is an easy workaround, but if a workaround is needed, doesn't that mean this actually _is_ a bug? Never mind, I contacted the author. According to http://www.opengroup.org/onlinepubs/9699919799/utilities/file.html: If the file named by the file operand does not exist, cannot be read, or the type of the file named by the file operand cannot be determined, this shall not be considered an error that affects the exit status. So, this is not in line with ls, cat, grep, cp, chmod, gzip, gunzip, cut, head, stat, wc, etc. which all return with a non-zero exit status when any of the given files does not exist. |