> Date: Tue, 20 Jan 2015 22:09:12 +0100
> From: Christian Weisgerber <[email protected]>
> 
> As proposed on misc@, here's a diff to bring our shutdown(8) in line
> with FreeBSD's and use plain "-p" to specify "halt and power down".
> Mostly from FreeBSD.

I'm fine with makeing "shutdown -p" equivalent to "shutdown -hp", but
I don't see why we have to break the latter.

> Index: shutdown.8
> ===================================================================
> RCS file: /cvs/src/sbin/shutdown/shutdown.8,v
> retrieving revision 1.39
> diff -u -p -r1.39 shutdown.8
> --- shutdown.8        19 Nov 2007 08:51:49 -0000      1.39
> +++ shutdown.8        20 Jan 2015 20:57:36 -0000
> @@ -58,7 +58,8 @@ The options are as follows:
>  .Bl -tag -width Ds
>  .It Fl d
>  When used with
> -.Fl h
> +.Fl h ,
> +.Fl p ,
>  or
>  .Fl r
>  causes system to perform a dump.
> @@ -93,18 +94,15 @@ does not actually halt the system, but l
>  system multi-user with logins disabled (for all but superuser).
>  .It Fl n
>  When used with
> -.Fl h
> +.Fl h ,
> +.Fl p ,
>  or
>  .Fl r
>  prevents the normal
>  .Xr sync 2
>  before stopping the system.
>  .It Fl p
> -The
> -.Fl p
> -flag is passed on to
> -.Xr halt 8 ,
> -causing machines which support automatic power down to do so after halting.
> +The system will turn the power off after shutdown if it can.
>  .It Fl r
>  .Nm
>  execs
> Index: shutdown.c
> ===================================================================
> RCS file: /cvs/src/sbin/shutdown/shutdown.c,v
> retrieving revision 1.38
> diff -u -p -r1.38 shutdown.c
> --- shutdown.c        16 Jan 2015 06:40:01 -0000      1.38
> +++ shutdown.c        20 Jan 2015 20:51:26 -0000
> @@ -153,14 +153,9 @@ main(int argc, char *argv[])
>                   "shutdown: incompatible switches -f and -n.\n");
>               usage();
>       }
> -     if (doreboot && dohalt) {
> +     if (doreboot + dohalt + dopower > 1) {
>               (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");
> +                 "shutdown: incompatible switches -h, -p and -r.\n");
>               usage();
>       }
>       getoffset(*argv++);
> @@ -333,7 +328,8 @@ die_you_gravy_sucking_pig_dog(void)
>  {
>  
>       syslog(LOG_NOTICE, "%s by %s: %s",
> -         doreboot ? "reboot" : dohalt ? "halt" : "shutdown", whom, mbuf);
> +         doreboot ? "reboot" : dohalt ? "halt" : dopower ? "power-down" :
> +         "shutdown", whom, mbuf);
>       (void)sleep(2);
>  
>       (void)printf("\r\nSystem shutdown time has arrived\007\007\r\n");
> @@ -348,6 +344,8 @@ die_you_gravy_sucking_pig_dog(void)
>               (void)printf("reboot");
>       else if (dohalt)
>               (void)printf("halt");
> +     else if (dopower)
> +             (void)printf("power-down");
>       if (nosync)
>               (void)printf(" no sync");
>       if (dofast)
> @@ -363,7 +361,7 @@ die_you_gravy_sucking_pig_dog(void)
>               syslog(LOG_ERR, "shutdown: can't exec %s: %m.", _PATH_REBOOT);
>               warn(_PATH_REBOOT);
>       }
> -     else if (dohalt) {
> +     else if (dohalt || dopower) {
>               execle(_PATH_HALT, "halt", "-l",
>                   (dopower ? "-p" : (nosync ? "-n" : (dodump ? "-d" : NULL))),
>                   (nosync ? "-n" : (dodump ? "-d" : NULL)),
> @@ -546,6 +544,7 @@ badtime(void)
>  void
>  usage(void)
>  {
> -     fprintf(stderr, "usage: shutdown [-] [-dfhknpr] time [warning-message 
> ...]\n");
> +     fprintf(stderr,
> +         "usage: shutdown [-] [-dfhknpr] time [warning-message ...]\n");
>       exit(1);
>  }
> -- 
> Christian "naddy" Weisgerber                          [email protected]
> 
> 

Reply via email to