[Bug 1055007] Re: cal output differs between 10.04.4 LTS and 12.04 LTS
Gary Peters
gary at homecu.com
Tue Aug 11 02:00:54 UTC 2015
I have existing scripts, many old and widely distributed, that were
written using the stdout of "cal" as the stdin of another command. The
problem (for existing scripts) is that cal changed its piped-output
behavior by inserting extra underscore and backspace characters, which
can cause problems for whatever command is reading cal's piped-output.
On Ubuntu 10.04 (and earlier) the cal's "-h" was automatically implied
when redirecting cal's stdout, but Ubuntu 12.04/14.04 do not behave in
the same manor.
This issue is not that cal has a beautified output when displayed on a
terminal, rather the issue (and hence the bug) is that cal should
intentionally not beautify the output when its stdout is not a terminal.
To see this, try the command on Ubuntu 12.04/14.04:
cal | od -c
and notice the underscore and backspace characters (they do not occur on Ubuntu 10.04 when redirecting cal's stdout).
A simple example -- on Ubuntu 10.04 this works as expected:
cal | sed 's/^/ /; s/$/ /' | grep -e " `date '+%e'` "
but to make it work on Ubuntu 12.04/14.04 now requires the explicit "-h" argument:
cal -h | sed 's/^/ /; s/$/ /' | grep -e " `date '+%e'` "
The crude work-around that I have had to implemented (for script backwards compatibility with non-linux servers) is to replace usage like:
cal 1 2000
with usage like:
( cal -h 1 2000 2> /dev/null || cal 1 2000 )
I have been using UNIX/Linux (and other flavors) for 34 years, and I
would have never expected such a standard and universal UNIX/Linux
command as "cal" to change in a manor that breaks existing scripts,
especially when it is just a case of testing if stdout is attached to a
terminal or not. Hence, I do not feel that it is a evolutionary growth
of the "cal" command (for which old scripts just must be rewritten for
the evolutionary good), but rather a bug that was not realized to be
occurring.
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to bsdmainutils in Ubuntu.
https://bugs.launchpad.net/bugs/1055007
Title:
cal output differs between 10.04.4 LTS and 12.04 LTS
Status in bsdmainutils package in Ubuntu:
Confirmed
Bug description:
Raw outputs (terminal output looks the same for both but programs get
it wrong):
10.04.4:
September 2012
Su Mo Tu We Th Fr Sa
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30
12.04:
September 2012
Su Mo Tu We Th Fr Sa
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
_^H2_^H3 24 25 26 27 28 29
30
Also "diff -B <( cal ) <( cal -h )" differs on 12.04 but not on
10.04.4
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/bsdmainutils/+bug/1055007/+subscriptions
More information about the foundations-bugs
mailing list