f5b wrote:
> Want
> Power off host at the specified time using "shutdown"
>
> OpenBSD
> # shutdown -ph 1501161730
>
> other BSDs
> # shutdown -p 1501161730
>
> Why? Will we sync?
>
> ----------------------------
> man shutdown 8 in OpenBSD
> -h The system is halted at the specified time when shutdown execs
> halt(8).
> -p The -p flag is passed on to halt(8), causing machines which
> support automatic power down to do so after halting.
>
>
It makes sense to me to imply -h when specifying -p.
To me the man page already implies the -h option when passing -p.
The code appears to require -h to be set for -p to work. I think making -h
implicit when specifying -p meets this requirement.
This patch changes that, it also removes a check that I think cannot be
triggered anymore.
(tested only once, use at your own risk !)
Index: shutdown.c
===================================================================
RCS file: /cvs/src/sbin/shutdown/shutdown.c,v
retrieving revision 1.38
diff -u -p -u -r1.38 shutdown.c
--- shutdown.c 16 Jan 2015 06:40:01 -0000 1.38
+++ shutdown.c 19 Jan 2015 12:03:03 -0000
@@ -134,6 +134,7 @@ main(int argc, char *argv[])
nosync = 1;
break;
case 'p':
+ dohalt = 1;
dopower = 1;
break;
case 'r':
@@ -156,11 +157,6 @@ main(int argc, char *argv[])
if (doreboot && dohalt) {
(void)fprintf(stderr,
"shutdown: incompatible switches -h and -r.\n");
- usage();
- }
- if (dopower && !dohalt) {
- (void)fprintf(stderr,
- "shutdown: switch -p must be used with -h.\n");
usage();
}
getoffset(*argv++);