Bug 2296201

Summary: fold exit code is zero for non-existent file
Product: [Fedora] Fedora Reporter: Sohum M <redhat.5exll>
Component: coreutilsAssignee: Lukáš Zaoral <lzaoral>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 40CC: admiller, jamartis, kdudka, kzak, lzaoral, nixuser, ovasik, p, svashisht, vmihalko
Target Milestone: ---Keywords: Desktop, Regression
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: coreutils-9.4-7.fc40 coreutils-9.3-6.fc39 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-07-17 02:33:21 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Sohum M 2024-07-07 19:15:05 UTC
Description of problem:
When using fold on a non-existent file, a zero exit code is returned.

Version-Release number of selected component (if applicable):
coreutils-9.4-6.fc40.src.rpm
Speculated to have existed since commit 66a4fe9b1acf28e5d156be7d84a2d7830a776b8b, see:
  * <https://src.fedoraproject.org/rpms/coreutils/blame/coreutils-i18n.patch?identifier=rawhide#2185>
  * <https://src.fedoraproject.org/rpms/coreutils/c/66a4fe9b1acf28e5d156be7d84a2d7830a776b8b>

Reproducible: Always

Steps to Reproduce:
1.
  $ fold badfile
  fold: badfile: No such file or directory
  $ echo "$?"
  0              # <<< should be non-zero 
Actual Results:  
The return code is successful.

Expected Results:  
If any file fails to open, the return code should be an error.

* I checked the upstream GNU coreutils sources, and they don't have this same error.
* I implemented a patch for this which should resolve it and tested it locally in a quay.io/fedora/fedora:40 container (Image: a0d555a3386f), but I'd appreciate any feedback.

Commit on my fork: https://src.fedoraproject.org/fork/ssmendon/rpms/coreutils/tree/7dd145deac885c3274b6557890e53a00e5c333b2
PR to coreutils/f40: https://src.fedoraproject.org/rpms/coreutils/pull-request/16#

Comment 1 Lukáš Zaoral 2024-07-09 06:21:17 UTC
Thank you for the report, Sohum!  I'll respond directly in the PR.

Comment 2 Fedora Update System 2024-07-15 10:58:34 UTC
FEDORA-2024-5e81f7f653 (coreutils-9.4-7.fc40) has been submitted as an update to Fedora 40.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-5e81f7f653

Comment 3 Fedora Update System 2024-07-15 10:58:37 UTC
FEDORA-2024-852cf8cfb3 (coreutils-9.3-6.fc39) has been submitted as an update to Fedora 39.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-852cf8cfb3

Comment 4 Fedora Update System 2024-07-16 01:25:39 UTC
FEDORA-2024-5e81f7f653 has been pushed to the Fedora 40 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2024-5e81f7f653`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2024-5e81f7f653

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 5 Fedora Update System 2024-07-16 02:10:28 UTC
FEDORA-2024-852cf8cfb3 has been pushed to the Fedora 39 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2024-852cf8cfb3`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2024-852cf8cfb3

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 6 Fedora Update System 2024-07-17 02:33:21 UTC
FEDORA-2024-5e81f7f653 (coreutils-9.4-7.fc40) has been pushed to the Fedora 40 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 7 Fedora Update System 2024-07-18 04:06:07 UTC
FEDORA-2024-852cf8cfb3 (coreutils-9.3-6.fc39) has been pushed to the Fedora 39 stable repository.
If problem still persists, please make note of it in this bug report.