[v3 PATCH 06/11] cal: make -w accept its optional argument

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx>
---
 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);
 
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux