cal -M (start week on Monday) don't work

Bug #908233 reported by Ivan Sorokin
84
This bug affects 18 people
Affects Status Importance Assigned to Milestone
bsdmainutils (Ubuntu)
Triaged
Low
Unassigned

Bug Description

man page says:

     -M Weeks start on Monday.

But when I run

$ cal -M
Usage: cal [general options] [-hjy] [[month] year]
       cal [general options] [-hj] [-m month] [year]
       ncal [general options] [-bhJjpwySM] [-s country_code] [[month] year]
       ncal [general options] [-bhJeoSM] [year]
General options: [-NC3] [-A months] [-B months]
For debug the highlighting: [-H yyyy-mm-dd] [-d yyyy-mm]

Revision history for this message
Dave Gilbert (ubuntu-treblig) wrote :

My reading is that the manpage isn't that clear about the fact that some options only work on ncal, not cal. The top of the man page does show that in the set of options (the same as the usage) - but it's hardly obvious, so it seems fair that the manpage could do with making it clearer.

Changed in bsdmainutils (Ubuntu):
importance: Undecided → Low
status: New → Triaged
Revision history for this message
Ivan Sorokin (sorokin) wrote :

Yes but both cal -M and ncal -M works perfectly in cygwin (I'm almost sure, I can check this later). So I think this is problem in code, not in manpage.

Revision history for this message
Dave Gilbert (ubuntu-treblig) wrote :

Hi Ivan,
  Hmm this is a bit complicated; there are two things going on - and I'm not sure which cygwin do:

1) bsdmainutils uses an oldschool Unix trick to use the same binary for cal and ncal; it decides what to do based on the name of the binary that it was run as; I'm not sure if cygwin does the same thing or not. Now, if it's run as 'cal' it sets a backwards compatibility flag.

2) The -M option doesn't seem to be in the bsdmainutils by default, but it comes from a patch in the debian package (ncal_mfdow.diff) and it has the code:

+ case 'M':
+ if (flag_backward)
+ usage();
+ weekstart = 1;
+ break;

So the intention there is pretty clear it wants that when in backward compatibility mode it wants to tell you M isn't supported.

So, not sure what cygwin uses.

Dave

Revision history for this message
Ralph Corderoy (ralph-inputplus) wrote :

Agreed, it's only the documentation that's misleading WRT -M not working for old cal.

Revision history for this message
Serhiy (xintx-ua) wrote :

Why does Ubuntu uses FreeBSD variant of cal while Linux variant of cal actually has the option "-m" for mondays? (AFAIU it should be in the util-linux package but it's not).

Revision history for this message
Dave Gilbert (ubuntu-treblig) wrote :

xintx-ua: I don't know why it uses the cal from bsdmainutil's rather than util-linux; but it seems pretty arbitrary.
  The version in util-linux appears to be a different piece of berkeley licensed code, but given that there is precisely
nothing Linux specific about cal or even vaguely systemy, I can't see why cal is in util-linux anyway.

Dave

Revision history for this message
Serhiy (xintx-ua) wrote :

In fact it's really not there. I found that fact on some old page.

Revision history for this message
Ilya Schurov (ily2) wrote :

Yes, it's very inconvenient that good old 'cal -m' or 'cal -3m' doesn't work in Ubuntu.

Are any workarounds e.g. to get sources (where?) and compile right version of cal which support -m or -M option?

Revision history for this message
apsaras (c-launchpad1) wrote :

A workaround is to use 'ncal -bM'. (Or even 'ncal -b' works on my system.)

I think what is confusing (apart from having two different commands for the same thing) is that cal used to have different behaviour. E.g., in Ubuntu 10.04, cal always started the week with Monday.

Revision history for this message
Rolf Leggewie (r0lf) wrote :

apsaras, what you are seeing is the regression documented in bug 939772. :-(

Revision history for this message
xerostomus (xerostomus) wrote :

The same applies for the option -w (number of weeks)
These two commands work correctly:
     ncal -w
     cal -N -w
This one does not:
     cal -w
there should be a warning in manual, that the option -w applies only for ncal variation.

Revision history for this message
Nikolaus Heinz (derdarky) wrote :

I added the following alias in my .bashrc

alias cal='ncal -bM'

Thank you apsaras.

To post a comment you must log in.
This report contains Public information  
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.