changed exit code for 'dc' in Ubuntu Bionic

Bug #1788681 reported by Wladimir Mutel on 2018-08-23
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
bc (Ubuntu)
Undecided
Unassigned
dphys-swapfile (Ubuntu)
Undecided
Axel Beckert

Bug Description

in Ubuntu Xenial :
$ lsb_release -rdc ; echo 1 1 + p q | dc ; echo $?
Description: Ubuntu 16.04.4 LTS
Release: 16.04
Codename: xenial
2
0

in Ubuntu Bionic :
$ lsb_release -rdc ; echo 1 1 + p q | dc ; echo $?
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic
2
1

This change causes some scripts using 'dc' to fail, most importantly, 'dphys-swapfile' which for some ironic reason uses 'dc' instead of 'echo $((...))' for its calculations.

Wladimir Mutel (mwg) wrote :

same is reproduced when you run 'dc', enter into it some expression ending with 'p q', and examining its exit code with 'echo $?' afterwards

Hi Wladimir,

Wladimir Mutel wrote:
> in Ubuntu Xenial :
> $ lsb_release -rdc ; echo 1 1 + p q | dc ; echo $?
> Description: Ubuntu 16.04.4 LTS
> Release: 16.04
> Codename: xenial
> 2
> 0
>
> in Ubuntu Bionic :
> $ lsb_release -rdc ; echo 1 1 + p q | dc ; echo $?
> Description: Ubuntu 18.04.1 LTS
> Release: 18.04
> Codename: bionic
> 2
> 1
>
> This change causes some scripts using 'dc' to fail, most importantly,
> 'dphys-swapfile'

Thanks for that bug report. This might be the cause for
https://bugs.debian.org/906767 which I'm currently trying to fix.

> which for some ironic reason uses 'dc' instead of 'echo
> $((...))' for its calculations.

That's upstream's decision. And since I know that upstream also runs
rather old Unices, I assume it's because $(( ... )) might not be
available in all shells. According to
https://en.wikipedia.org/wiki/Comparison_of_command_shells#cite_ref-57
it should though be available in all relevant shells since 1992.

The relevant change in dc seems to be from 1.3 to 1.4:

    Detects and reports on any output errors; exits non-success.

The fix seems simple: Drop the "q":

~ → echo 1 1 + p q | dc ; echo $?
2
1
~ → echo 1 1 + p | dc ; echo $?
2
0

Will have to check if that's indeed the cause for
https://bugs.debian.org/906767, but will do a new upload to Debian
Unstable in either case.

Someone else will need to take care of a regression fix for bionic
though.

  Regards, Axel
--
 ,''`. | Axel Beckert <email address hidden>, https://people.debian.org/~abe/
: :' : | Debian Developer, ftp.ch.debian.org Admin
`. `' | 4096R: 2517 B724 C5F6 CA99 5329 6E61 2FF9 CD59 6126 16B5
  `- | 1024D: F067 EA27 26B9 C3FC 1486 202E C09E 1D89 9593 0EDE

tags: added: bionic cosmic
Changed in dphys-swapfile (Ubuntu):
status: New → Confirmed
Axel Beckert (xtaran) on 2018-08-23
Changed in dphys-swapfile (Ubuntu):
assignee: nobody → Axel Beckert (xtaran)
status: Confirmed → In Progress
Axel Beckert (xtaran) on 2018-08-23
Changed in dphys-swapfile (Ubuntu):
status: In Progress → Fix Committed
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package dphys-swapfile - 20100506-5

---------------
dphys-swapfile (20100506-5) unstable; urgency=high

  * Add patch to fix the setup subcommand exiting prematurely with more
    recent dc versions. (Closes: #906767, LP: #1788681) Also update
    check-diskspace-first.patch which uses the same syntax. Thanks to
    eHenry Berg for the initial bug report, Davide Prina for additional
    debugging help, and Wladimir Mutel for finding the actual culprit.

 -- Axel Beckert <email address hidden> Thu, 23 Aug 2018 23:29:41 +0200

Changed in dphys-swapfile (Ubuntu):
status: Fix Committed → Fix Released
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in bc (Ubuntu):
status: New → Confirmed
Paul Graydon (twirrim) wrote :

Fix has only been released for Cosmic. Given the package is basically non-functional on Bionic, is there a plan to backport the fix? There doesn't seem much point in keeping it in the repository otherwise.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.