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
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1055007

Title:
  cal output differs between 10.04.4 LTS and 12.04 LTS

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/bsdmainutils/+bug/1055007/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to