Bug 249465 - Stat always returns exit status of 0
Stat always returns exit status of 0
Status: CLOSED DUPLICATE of bug 231019
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: coreutils (Show other bugs)
4.5
i386 Linux
low Severity medium
: ---
: ---
Assigned To: Tim Waugh
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2007-07-24 16:30 EDT by Nicholas, Crawford
Modified: 2007-11-16 20:14 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2007-07-30 10:29:02 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Nicholas, Crawford 2007-07-24 16:30:35 EDT
Description of problem:
stat always returns an exit status of 0

Version-Release number of selected component (if applicable):
coreutils-5.2.1-31.6

How reproducible:
every time

Steps to Reproduce:
1. Stat a non-existant file
2. echo $?
  
Actual results:
[root@rhel4 ~]# /usr/bin/stat /bin/bash
  File: `/bin/bash'
  Size: 616248          Blocks: 1216       IO Block: 4096   regular file
Device: 802h/2050d      Inode: 2490433     Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2007-07-24 16:25:02.000000000 -0400
Modify: 2006-04-12 16:01:32.000000000 -0400
Change: 2007-07-23 14:47:24.000000000 -0400
[root@rhel4 ~]# echo $?
0
[root@rhel4 ~]# /usr/bin/stat /bin/noexist
/usr/bin/stat: cannot stat `/bin/noexist': No such file or directory
[root@rhel4 ~]# echo $?
0

Expected results:
[root@rhel5 ~]# /usr/bin/stat /bin/bash
  File: `/bin/bash'
  Size: 722684          Blocks: 1432       IO Block: 4096   regular file
Device: 901h/2305d      Inode: 3365258     Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2007-07-24 16:25:01.000000000 -0400
Modify: 2007-01-05 23:24:14.000000000 -0500
Change: 2007-05-07 08:21:27.000000000 -0400
[root@rhel5 ~]# echo $?
0
[root@rhel5 ~]# /usr/bin/stat /bin/noexist
/usr/bin/stat: cannot stat `/bin/noexist': No such file or directory
[root@rhel5 ~]# echo $?
1

Additional info:
Comment 1 Jim Meyering 2007-07-25 09:06:55 EDT
Thanks for the report.  FYI, that was fixed upstream in coreutils-5.90 
(2005-09-29) [unstable].

From NEWS:

  stat now exits nonzero if a file operand does not exist
Comment 2 Tim Waugh 2007-07-30 10:29:02 EDT

*** This bug has been marked as a duplicate of 231019 ***

Note You need to log in before you can comment on or make changes to this bug.