Bug 249465 - Stat always returns exit status of 0
Summary: Stat always returns exit status of 0
Keywords:
Status: CLOSED DUPLICATE of bug 231019
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: coreutils
Version: 4.5
Hardware: i386
OS: Linux
low
medium
Target Milestone: ---
: ---
Assignee: Tim Waugh
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2007-07-24 20:30 UTC by Nicholas, Crawford
Modified: 2007-11-17 01:14 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2007-07-30 14:29:02 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Nicholas, Crawford 2007-07-24 20:30:35 UTC
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 13:06:55 UTC
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 14:29:02 UTC

*** 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.