Bug 1211629 - rpmbuild ignores failed shell AND-command list
Summary: rpmbuild ignores failed shell AND-command list
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: rpm
Version: 20
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Packaging Maintenance Team
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-04-14 13:17 UTC by Petr Pisar
Modified: 2015-04-15 13:34 UTC (History)
8 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2015-04-15 13:34:31 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Reproducer (345 bytes, text/plain)
2015-04-14 13:17 UTC, Petr Pisar
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1210754 0 medium CLOSED Review Request: json - JSON for Modern C++ 2021-02-22 00:41:40 UTC

Internal Links: 1210754

Description Petr Pisar 2015-04-14 13:17:26 UTC
Created attachment 1014306 [details]
Reproducer

Building a package with this code passes:

%check
false && false

I think it should fail.

Reproducer attached.

It does not happen with "false || false" or "false ; false".

Tested with rpm-build-4.11.3-2.fc20.x86_64 as well as with rpm-build-4.12.0.1-13.fc23.x86_64.

Comment 1 Ľuboš Kardoš 2015-04-15 07:24:06 UTC
This behaves like this because of shell. Try following:
$ set -e
$ false && false   # Shell doesn't exit
$ false || false   # Shell exits immediately 

Moving to bash to explain this behaviour.

Comment 2 Ondrej Oprala 2015-04-15 08:07:49 UTC
Hi Ľuboš, the bash man page describing set -e mentions this in more detail.
In a nutshell, for && and ||, only the return exit of the command after the last && or || is considered when 'set -e' is switched on. As the first false is enough to determine the truth value of the '&&' expression, the second false is never executed, thus there's no return value to judge upon. All shells behave this way (or should, at the very least, I tried with ksh and zsh).

I don't know what rpmbuild switches on or off when running spec scripts, but it's not a shell bug.

Comment 3 Ľuboš Kardoš 2015-04-15 13:34:31 UTC
But this is not a bug in rpm either. rpm doesn't parse or execute these scripts itself but it depends on what is returned from bash.


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