From: J William Piggott <elseifthen@gmx.com>
To: Karel Zak <kzak@redhat.com>
Cc: util-linux@vger.kernel.org
Subject: [v3 PATCH 06/11] cal: make -w accept its optional argument
Date: Tue, 2 Jan 2018 09:59:07 -0500 [thread overview]
Message-ID: <88ccbbdb-28f2-a9e6-1918-531333c94c71@gmx.com> (raw)
In-Reply-To: <4833b897-2192-86dc-f81b-e977d98b07b1@gmx.com>
This was removed in commit af7c483 due a mailing list comment:
https://marc.info/?l=util-linux-ng&m=138116560906549&w=2
It's generally best to avoid optional args on short args,
as in this case -w3 is ambiguous and -wj is problematic.
So I'd instead support an interface like -w,--week[=NUM]
cal -wj
cal: invalid week argument: 'j'
cal -w3
January 2018
Su Mo Tu We Th Fr Sa
1 1 2 3 4 5 6
2 7 8 9 10 11 12 13
3 14 15 16 17 18 19 20
4 21 22 23 24 25 26 27
5 28 29 30 31
That should be an expected result for those commands.
Util-linux has many commands with optional args for short options:
ipcrm, swapon, lscpu, nsenter, dmesg, script, cfdisk, fdisk, hexdump
It seems unexpected to have an argument for long options only. I found
this because I tried to pass an argument to -w.
Signed-off-by: J William Piggott <elseifthen@gmx.com>
---
misc-utils/cal.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/misc-utils/cal.c b/misc-utils/cal.c
index 2f0a6be16..02283bc04 100644
--- a/misc-utils/cal.c
+++ b/misc-utils/cal.c
@@ -354,7 +354,7 @@ int main(int argc, char **argv)
ctl.weekstart = (wfd + *nl_langinfo(_NL_TIME_FIRST_WEEKDAY) - 1) % DAYS_IN_WEEK;
}
#endif
- while ((ch = getopt_long(argc, argv, "13mjn:sSywYVh", longopts, NULL)) != -1) {
+ while ((ch = getopt_long(argc, argv, "13mjn:sSyw::YVh", longopts, NULL)) != -1) {
err_exclusive_options(ch, longopts, excl, excl_st);
next prev parent reply other threads:[~2018-01-02 14:59 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-02 14:53 [v3 PATCH 00/11] Pull Request - changelog J William Piggott
2018-01-02 14:54 ` [v3 PATCH 01/11] cal: change default output format J William Piggott
2018-01-02 14:55 ` [v3 PATCH 02/11] cal: change reformation to reform J William Piggott
2018-01-02 14:56 ` [v3 PATCH 03/11] cal: update man page and usage() J William Piggott
2018-01-02 14:57 ` [v3 PATCH 04/11] cal: rename --julian to --ordinal J William Piggott
2018-01-02 14:58 ` [v3 PATCH 05/11] cal: add private --caesar option J William Piggott
2018-01-02 14:59 ` J William Piggott [this message]
2018-01-02 14:59 ` [v3 PATCH 07/11] cal: update mutually exclusive options J William Piggott
2018-01-02 15:00 ` [v3 PATCH 08/11] cal: add short versions of new options J William Piggott
2018-01-02 15:01 ` [v3 PATCH 09/11] cal: remove the non-functional options J William Piggott
2018-01-02 15:02 ` [v3 PATCH 10/11] cal: fix first week calculation J William Piggott
2018-01-02 15:02 ` [v3 PATCH 11/11] cal: fix week calculations for --1752-reform J William Piggott
2018-01-03 10:06 ` [v3 PATCH 00/11] Pull Request - changelog Karel Zak
2018-01-08 10:21 ` Karel Zak
2018-01-09 1:17 ` J William Piggott
2018-01-24 18:13 ` Ruediger Meier
2018-01-11 2:00 ` J William Piggott
2018-01-11 9:01 ` Karel Zak
2018-01-11 13:35 ` J William Piggott
2018-01-12 10:57 ` Karel Zak
2018-01-15 2:02 ` J William Piggott
2018-01-15 13:36 ` Karel Zak
2018-01-16 21:35 ` J William Piggott
2018-01-16 21:39 ` [v5 PATCH 1/3] cal: move REFORMATION_YEAR to control struct J William Piggott
2018-01-16 21:41 ` [v5 PATCH 2/3] cal: add option to set Gregorian reform date J William Piggott
2018-01-16 21:42 ` [v5 PATCH 3/3] cal: update man page J William Piggott
2018-01-17 12:08 ` [v3 PATCH 00/11] Pull Request - changelog Karel Zak
2018-01-18 16:32 ` J William Piggott
2018-01-22 11:46 ` Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=88ccbbdb-28f2-a9e6-1918-531333c94c71@gmx.com \
--to=elseifthen@gmx.com \
--cc=kzak@redhat.com \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).