[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: [PATCH] date: return failure exit code on set time error
From:       Ladislav Michl <oss-lists () triops ! cz>
Date:       2023-06-27 14:11:12
Message-ID: ZJruAIjSAVaQBzPN () lenoch
[Download RAW message or body]

Gentle ping... Not possible to do any reasonable scripting as date
claims to be successfull all the time.

Coreutils-8.32 date does:

      if (set_date)
        {
          /* Set the system clock to the specified date, then regardless of
             the success of that operation, format and print that date.  */
          if (settime (&when) != 0)
            {
              error (0, errno, _("cannot set date"));
              ok = false;
            }
        }
[snip]
  return ok ? EXIT_SUCCESS : EXIT_FAILURE;

On Wed, Jun 14, 2023 at 04:35:06PM +0200, Ladislav Michl wrote:
> From: Ladislav Michl <ladis@linux-mips.org>
> 
> Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
> ---
>  coreutils/date.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/coreutils/date.c b/coreutils/date.c
> index abcc37c33..0fca89369 100644
> --- a/coreutils/date.c
> +++ b/coreutils/date.c
> @@ -289,7 +289,7 @@ int date_main(int argc UNUSED_PARAM, char **argv)
>  
>  		/* if setting time, set it */
>  		if ((opt & OPT_SET) && clock_settime(CLOCK_REALTIME, &ts) < 0) {
> -			bb_simple_perror_msg("can't set date");
> +			bb_perror_msg_and_die("can't set date");
>  		}
>  	}
>  
> -- 
> 2.39.2
> 
> _______________________________________________
> busybox mailing list
> busybox@busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic