[PATCH] date: return failure exit code on set time error
Ladislav Michl
oss-lists at triops.cz
Tue Jun 27 14:11:12 UTC 2023
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 at linux-mips.org>
>
> Signed-off-by: Ladislav Michl <ladis at 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 at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
More information about the busybox
mailing list